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

using namespace std;
using ll = long long;
// #define int ll
using PII = pair<ll, ll>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()

template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type
fill_v(T &t, const V &v) { t=v; }
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t, const V &v ) { for(auto &e:t) fill_v(e,v); }

template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a) {
    out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
    out<<'[';
    for(const T &i: a) out<<i<<',';
    out<<']';
    return out;
}
template<class T>
ostream &operator <<(ostream& out, const set<T>& a) {
    out<<'{';
    for(const T &i: a) out<<i<<',';
    out<<'}';
    return out;
}
template<class T, class S>
ostream &operator <<(ostream& out, const map<T,S>& a) {
    out<<'{';
    for(auto &i: a) out<<i<<',';
    out<<'}';
    return out;
}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;

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

    ll x, y, z, k;
    cin >> x >> y >> z >> k;
    vector<ll> a(x), b(y), c(z);
    REP(i, x) cin >> a[i];
    REP(i, y) cin >> b[i];
    REP(i, z) cin >> c[i];

    sort(ALL(a), greater<>());
    sort(ALL(b), greater<>());
    sort(ALL(c), greater<>());

    vector<ll> v;
    REP(i, x) REP(j, y) v.push_back(a[i]+b[j]);
    sort(ALL(v), greater<>());
    vector<ll> vs;
    REP(i, min(k,(ll)v.size())) REP(j, z) vs.push_back(v[i]+c[j]);
    sort(ALL(vs), greater<>());

    REP(i, k) cout << vs[i] << endl;

    return 0;
}


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

int main() {
  int n;
  cin>>n;
  vector<int> l(n);
  rep(i,n) cin>>l[i];
  sort(l.begin(),l.end()); 
  int ans=0;
  for (int i=0; i<n-1; i++) {
    for (int j=i+1; j<n; j++) {
      int two=l[i]+l[j];
      auto itr=lower_bound(l.begin(),l.end(),two);
      int d=itr-l.begin();
      ans+=max(d-j-1,0);
    }
  }
  cout<<ans<<endl;
  return 0;
}
	

Measured memory_bytes: 256
import java.util.*;

public class Main {

    static int H;
    static int W;
    static char[][] map;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        H = sc.nextInt();
        W = sc.nextInt();
        
        map = new char[H][W];

        for (int i = 0; i < H; i++) {
            map[i] = sc.next().toCharArray();
        }

        for (int y = 0; y < H; y++) {
            for (int x = 0; x < W; x++) {
                if (map[y][x] == '#') {
                    boolean isOk = false;
                    if (find(x + 1, y)) {
                        isOk = true;
                    }
                    if (find(x - 1, y)) {
                        isOk = true;
                    }
                    if (find(x, y + 1)) {
                        isOk = true;
                    }
                    if (find(x, y - 1)) {
                        isOk = true;
                    }

                    if (!isOk) {
                        System.out.println("No");
                        return;
                    }
                }

            }
        }

        System.out.println("Yes");
    }

    public static boolean find(int x, int y) {
        if (x < 0 || y < 0 || x >= W || y >= H) {
            return false;
        }

        return map[y][x] == '#';
    }
}


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

using namespace std;

struct Point{
    int cost, x, y;
    bool operator < (const Point &o) const {
        return cost > o.cost;
    }
};

int h, w;
priority_queue<Point> q;
int c[1010][1010];
int m[1010][1010];
int vis[1010][1010];
int color[1010][1010];

int insize(int x, int y)
{
    return 1 <= x && x <= h && 1 <= y && y <= w && !m[x][y];
}

void dfs(int x, int y, int col)
{
    color[x][y] = col;
    if(insize(x+1, y) && !color[x+1][y]) dfs(x+1, y, col);
    if(insize(x-1, y) && !color[x-1][y]) dfs(x-1, y, col);
    if(insize(x, y+1) && !color[x][y+1]) dfs(x, y+1, col);
    if(insize(x, y-1) && !color[x][y-1]) dfs(x, y-1, col);
}

int main()
{
    scanf("%d%d", &h, &w);
    int hc, wc, hd, wd;
    scanf("%d%d%d%d", &hc, &wc, &hd, &wd);
    for(int i = 1; i <= h; ++i)
        for(int j = 1; j <= w; ++j){
            char c;
            scanf(" %c", &c);
            m[i][j] = c == '#';
        }

    int cnt = 0;
    for(int i = 1; i <= h; ++i)
        for(int j = 1; j <= w; ++j)
            if(!m[i][j] && !color[i][j])
                dfs(i, j, ++cnt);


    q.push({0, hc, wc});
    memset(c, 0x3f, sizeof(c));
    c[hc][wc] = 0;
    while(!q.empty())
    {
        int x = q.top().x, y = q.top().y; q.pop();
        if(vis[x][y]) continue;
        vis[x][y] = 1;

        for(int dx = -2; dx <= 2; ++dx)
            for(int dy = -2; dy <= 2; ++dy)
            {
                int cost = color[x][y] != color[x+dx][y+dy];
                if(insize(x+dx, y+dy) && c[x+dx][y+dy] > c[x][y]+cost)
                {
                    c[x+dx][y+dy] = c[x][y]+cost;
                    q.push({c[x+dx][y+dy], x+dx, y+dy});
                }
            }
    }

    if(c[hd][wd] == 0x3f3f3f3f)
    {
        puts("-1");
        return 0;
    }
    printf("%d\n", c[hd][wd]);
}


Measured memory_bytes: 19672
#include <iostream>
#include <cstring>
using namespace std;
int main(){
  int n;
  cin >> n;
  char s[n][15], temp[15], tp;
  int p[n],num[n];
  for(int i=0; i<n; i++){
    cin >> s[i] >> p[i];
    num[i]=i+1;
  }
  for(int i=0; i<n; i++){
    for(int j=n-1; j>i; j--){
      if(strcmp(s[j],s[j-1])<0 ||(strcmp(s[j],s[j-1])==0&&p[j]>p[j-1])){
	swap(p[j-1], p[j]);
		swap(num[j-1], num[j]);
	strcpy(temp,s[j]);
	strcpy(s[j],s[j-1]);
	strcpy(s[j-1],temp);
      }
    }
  }
  for(int i=0; i<n; i++)
    cout << num[i] << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define repk(i,k,n) for (ll i = k; i < (ll)(n); ++i)
#define INF 500000001000000000
#define MOD 1000000007
typedef long long  ll;

using namespace std;
typedef pair<int, int> P;

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

	ll N,M;
	cin >> N >> M;

	vector<ll> dp(N+1,INF);
	dp[0] = 1;
	rep(i,M){
		ll a;
		cin >> a;
		dp[a] = 0;
	}

	repk(i,1,N+1){
		if(dp[i] == INF){
			if(i == 1) dp[i] = 1;
			else{
				dp[i] = (dp[i-1] + dp[i-2]) % MOD;
			}
		}
	}
	
	cout << dp[N] << endl;

	return 0;
}

Measured memory_bytes: 1024
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

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

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let n: usize = iterator.next().unwrap().parse().unwrap();
    let mut a: Vec<usize> = iterator.map(|s| s.parse().unwrap()).collect();

    // let cnt = bubble_sort(&mut a);
    // return cnt.to_string();

    let ans = merge_sort(&mut a, 0, n);

    return ans.to_string();
}

fn merge_sort(a: &mut Vec<usize>, left: usize, right: usize) -> usize {
    if left + 1 < right {
        let mid = (left + right) / 2;
        let mut count = 0;
        count += merge_sort(a, left, mid);
        count += merge_sort(a, mid, right);
        count += merge(a, left, mid, right);
        count
    } else {
        0
    }
}

fn merge(a: &mut Vec<usize>, left: usize, mid: usize, right: usize) -> usize {
    let n1 = mid - left;
    let n2 = right - mid;
    let mut l: Vec<usize> = Vec::new();
    let mut r: Vec<usize> = Vec::new();
    for i in 0..n1 {
        l.push(a[left + i]);
    }
    l.push(std::usize::MAX);
    for i in 0..n2 {
        r.push(a[mid + i]);
    }
    r.push(std::usize::MAX);

    let mut count = 0;

    let mut i = 0;
    let mut j = 0;
    for k in left..right {
        if l[i] <= r[j] {
            a[k] = l[i];
            i += 1;
        } else {
            a[k] = r[j];
            j += 1;
            count += n1 - i;
        }
    }

    count
}

// fn bubble_sort(a: &mut Vec<usize>) -> usize {
//     let mut cnt = 0;
//     for i in 0..a.len() {
//         for j in ((i + 1)..a.len()).rev() {
//             if a[j] < a[j - 1] {
//                 a.swap(j, j - 1);
//                 cnt += 1;
//             }
//         }
//     }
//     cnt
// }



Measured memory_bytes: 11076
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)
	x := nextInt()
	n := nextInt()

	p := make([]int, n)
	for i := 0; i < n; i++ {
		p[i] = nextInt()
	}

	for i := 0; i <= n; i++ {
		if !contain(p, x-i) {
			fmt.Println(x - i)
			return
		}
		if !contain(p, x+i) {
			fmt.Println(x + i)
			return
		}
	}
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func contain(h []int, n int) bool {
	for _, v := range h {
		if n == v {
			return true
		}
	}
	return false
}


Measured memory_bytes: 1756
#define _GIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;


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

  map<ll, int> m;
  rep(i, n) {
    m[a[i]]++;
  }

  pair<ll, int>  e1 = make_pair(0, 0);
  pair<ll, int>  e2 = make_pair(0, 0);
  for (auto x: m) {
    if (x.second < 2) continue;
    if (x.first > e1.first) {
      e2.first = e1.first;
      e2.second = e1.second;
      e1.first = x.first;
      e1.second = x.second;
    } else if (x.first > e2.first) {
      e2.first = x.first;
      e2.second = x.second;
    }
  }

  ll ans = 0;
  if (e1.second >= 4) {
    ans = e1.first * e1.first;
  } else {
    ans = e1.first * e2.first;
  }

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

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

typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define dump(x)  cout << #x << " = " << (x) << endl;	//debug
#define SZ(x) ((int)(x).size())
#define REP(i, n) for(ll i = 0; i < (n); i++)
#define REPR(i, n) for (ll i = (n); i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)

int main() {
	ll n;
	ll res = 0;
	cin >> n;
	res = n / 2;
	if (n % 2 == 1) {
		res++;
	}
	cout << res << endl;
	return(0);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SZ(x) ((int) (x).size())
using namespace std;

int main() {
    #ifdef LOCAL_RUN
    freopen("task.in", "r", stdin);
    freopen("task.out", "w", stdout);
    //freopen("task.err", "w", stderr);
    #endif // ONLINE_JUDGE
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n;
    cin >> n;

    map<int64_t, int> cnt;
    cnt[0] = 1;
    int64_t ans = 0;
    int64_t sum = 0;
    for (int i = 0; i < n; ++i) {
        int x;
        cin >> x;
        sum += x;
        ans += cnt[sum];
        cnt[sum]++;
    }
    cout << ans << '\n';
}


Measured memory_bytes: 12800
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define all(c) begin(c), end(c)
const int INF =
    sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = 1e9 + 7;
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

using Weight = int;
struct Edge {
    int s, d;
    Weight w;
    Edge(){};
    Edge(int s, int d, Weight w) : s(s), d(d), w(w){};
};
bool operator<(const Edge &e1, const Edge &e2) {
    return e1.w == e2.w ? (e1.s == e2.s ? e1.d < e2.d : e1.s < e2.s)
                        : e1.w < e2.w;
}
bool operator>(const Edge &e1, const Edge &e2) { return e2 < e1; }
inline ostream &operator<<(ostream &os, const Edge &e) {
    return (os << '(' << e.s << ", " << e.d << ", " << e.w << ')');
}

using Edges = vector<Edge>;
using Graph = vector<Edges>;
using Array = vector<Weight>;
using Matrix = vector<Array>;

void addArc(Graph &g, int s, int d, Weight w = 1) {
    g[s].emplace_back(s, d, w);
}
void addEdge(Graph &g, int a, int b, Weight w = 1) {
    addArc(g, a, b, w);
    addArc(g, b, a, w);
}

auto bfs = [](const Graph &g, int s, Array &dist) {
    int n = g.size();
    vector<bool> vis(n);
    vector<int> prev(n, -1);
    dist.assign(n, INF);
    dist[s] = 0;
    using State = tuple<Weight, int, int>;
    queue<State> q;
    q.emplace(0, s, -1);
    while (q.size()) {
        Weight d;
        int v, p;
        tie(d, v, p) = q.front();
        q.pop();
        vis[v] = true;
        prev[v] = p;
        for (auto &e : g[v]) {
            if (vis[e.d]) continue;
            if (dist[e.d] > dist[v] + e.w) {
                dist[e.d] = dist[v] + e.w;
                q.emplace(dist[e.d], e.d, v);
            }
        }
    }
    return prev;
};

auto getEdges = [](const Graph &g) {
    Edges ret;
    for (auto &es : g)
        for (auto &e : es) ret.emplace_back(e);
    return ret;
};

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int H, W;
    cin >> H >> W;
    Graph G(H * W);
    vector<string> s(H);
    rep(i, 0, H) cin >> s[i];
    int w = 0;
    rep(i, 0, H) {
        rep(j, 0, W) {
            int di[] = {0, 1, 0, -1};
            int dj[] = {1, 0, -1, 0};
            if (s[i][j] == '#') continue;
            w++;
            rep(d, 0, 4) {
                int ni = i + di[d];
                int nj = j + dj[d];
                if (0 <= ni && ni < H && 0 <= nj && nj < W && s[ni][nj] == '.')
                    addEdge(G, i * W + j, ni * W + nj);
            }
        }
    }
    Array dist;
    bfs(G, 0, dist);
    if (dist[H * W - 1] != INF) {
        cout << w - 1 - dist[H * W - 1] << endl;
    } else {
        cout << -1 << endl;
    }
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define int long long 
#define w(e) int e ; cin >> e ; while (e--)  
#define ll long long 
#define endl "\n"
#define mod  10000000007
#define pi 3.1415926535897932384626433
#define setbit(x) __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)  
/*
*/
int32_t main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n , k ; cin >> n >> k ;
    int cnt=0;
    int a[n] ; 
    int b[n] ; memset (b, 0, sizeof(b));
    int d ; 
    while (k--)
    {
    cin >> d ;
    for (int i=0 ;i<d ;i++)
    {
        cin >> a[i] ;
        b[a[i]-1]++;
    }

    }
    for (int i=0 ;i<n;i++)
    {
        if (b[i]==0)
            cnt++;
    }
    cout << cnt << endl;
	return  0;
}

Measured memory_bytes: 3564
N = int(input())
s = []
t = []
for i in range(N):
    s.append(input())
M = int(input())

for i in range(M):
    t.append(input())
mmax = -200
for i in s:
    m = 0
    for j in s:
        if i == j:
            m += 1
    for j in t:
        if i == j:
            m -= 1
    if mmax < m:
        mmax = m
    if mmax < 0:
        mmax = 0

print(mmax)

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

int main() {
	int n;
	cin >> n;
	int arr[n];
	for (int i=0; i<n; i++){
		cin>> arr[i];
	}
    if (n%2==0){
      for (int i=n-1; i>=0; i--){
          if (i%2==1) cout << arr[i]<<' ';
      }
      for (int i=0; i<n; i++){
          if (i%2==0) cout << arr[i]<<' ';
      }
    }
  	else{ 
      for (int i=n-1; i>=0; i--){
          if (i%2==0) cout << arr[i]<<' ';
      } 
      for (int i=0; i<n; i++){
          if (i%2==1) cout << arr[i]<<' ';
      } 
    }
	cout << endl;
}


Measured memory_bytes: 2944
<?php
$a = trim(fgets(STDIN));
$n = strlen($a);
$c[0] = 0;
for($i = 0; $i < $n; $i++){
  if($a[$i] == '<'){
    $c[$i+1] = $c[$i] + 1;
  }else{
    $c[$i+1] = 0;
  }
}
$d[$n] = 0;
for($i = $n-1; $i >= 0; $i--){
  if($a[$i] == '>'){
    $d[$i] = $d[$i+1] + 1;
  }else{
    $d[$i] = 0;
  }
}
$ans = 0;
for($i = 0; $i <= $n; $i++){
    $ans+=max($c[$i],$d[$i]);
}
echo $ans;


Measured memory_bytes: 41456
N=int(input())
a=list(map(int,input().split()))

ave=sum(a)/len(a)
k=abs(ave-a[0])
m=[]
for i in range(N):
    if abs(ave-a[i])<=k:
        k=abs(ave-a[i])
        
for i in range(N):
    if abs(ave-a[i])==k:
        print(i)
        break

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

using namespace std;

#define DUMP(x) std::cerr << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, k, n) for (int i = (k); i < (int)(n); ++i)
#define ALL(r) r.begin(), r.end()
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define IMP cout << "IMPOSSIBLE" << endl
#define Imp cout << "Impossible" << endl
#define imp cout << "impossible" << endl
#define M1 cout << "-1" << endl
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

template <typename T>
ostream &operator<<(ostream &os, vector<T> &v)
{
    os << "{";
    rep(i, v.size()) os << v[i] << (i == (int)v.size() - 1 ? "" : ", ");
    os << "}";
    return os;
}
template <typename T, typename U>
ostream &operator<<(ostream &os, pair<T, U> &p)
{
    os << "(" << p.first << ", " << p.second << ")";
    return os;
}
template <typename T>
T dup(T x, T y)
{
    return (x + y - 1) / y;
};
template <typename A, size_t N, typename T>
inline void arrayFill(A (&array)[N], const T &val) { std::fill((T *)array, (T *)(array + N), val); }
struct in
{
    const size_t n = 0;
    in() = default;
    in(size_t n) : n(n){};
    template <typename T>
    operator T()
    {
        T ret;
        cin >> ret;
        return ret;
    }
    template <typename T>
    operator vector<T>()
    {
        assert(n != 0);
        vector<T> ret(n);
        for (auto &x : ret)
            cin >> x;
        return ret;
    }
};

using ll = int64_t;
using vint = vector<int32_t>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pint = pair<int32_t, int32_t>;
using vpint = vector<pint>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
using setint = set<int32_t>;
using setstr = set<string>;
using qint = queue<int32_t>;
using qpint = queue<pint>;

constexpr std::int32_t INF = 1001001001;
constexpr std::int64_t LINF = 1001001001001001001;

void Main()
{
    int n = in(), k = in();
    ll ans = 0;
    vll num(k + 4, 0);
    for (int i = 1; i <= n; ++i)
        ++num[i % k];

    rep(a, k)
    {
        int b = (k - a) % k;
        int c = (k - a) % k;
        if ((b + c) % k)
            continue;
        ans += num[a] * num[b] * num[c];
    }
    cout << ans << endl;
}

signed main()
{
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 1792
mod=998244353
import sys
input=sys.stdin.readline
n,k=map(int,input().split())
lr=[]
for i in range(k):
	l,r=map(int,input().split())
	lr.append((l,r))
lr.sort()

cnt=[0]*n
cnt[0]=1
dp=[0]*n
for i in range(n-1):
	cnt[i]+=dp[i]
	for x,y in lr:
		if i+x<n:
			dp[i+x]+=cnt[i]
			dp[i+x]%=mod
		if i+y<n-1:
			dp[i+y+1]-=cnt[i]
			dp[i+y+1]%=mod
	dp[i]%=mod
	cnt[i]%=mod
	dp[i+1]+=dp[i]
print((cnt[-1]+dp[-1])%mod)

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

int main() {
	// your code goes here
	int N;
	cin >> N;
	int a[N];
	int i;
	int a1[N],a2[N],a3[N];
	int num[100001];
	int max=0;
	for(i=0;i<100001;i++){
		num[i] = 0;
	}
	for(i=0;i<N;i++){
	   cin >> a[i];
	   a1[i] = a[i]-1;
	   a2[i] = a[i];
	   a3[i] = a[i]+1;
	}
	for(i=0;i<N;i++){
		num[a1[i]]++;
		num[a2[i]]++;
		num[a3[i]]++;
	}
	for(i=0;i<100001;i++){
		if(max < num[i]){
			max = num[i];
		}
	}
	cout << max << '\n';
	return 0;
}

Measured memory_bytes: 2176
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(input())
def inpl(): return list(map(int, input().split()))
def inpl_s(): return list(input().split())
atoz = [chr(i) for i in range(97,97+26)]

N = inp()
aa = inpl()
xorSUM = SUM = 0
r = 0
ans = 0
for l in range(N):
	while xorSUM == SUM:
		ans += r-l
		r += 1
		if r > N:
			break
		xorSUM ^= aa[r-1]
		SUM += aa[r-1]
	else:
		SUM -= aa[l]
		xorSUM ^= aa[l]
		continue
	break
print(ans)


Measured memory_bytes: 25416
K = int(input())
#
# import fractions
# 
# def common(a, b):
#     return fractions.gcd(a, b)


import math
import itertools


def common(a, b):
    return math.gcd(a, b)


def calculate(k):
    sum = 0
    for i in itertools.combinations([i for i in range(1,k+1)],2):
        val1 = common(i[0],i[1]) * 6
        sum = sum + val1

    for i in range(1,k+1):
        val1 = i
        sum = sum + val1

    for  i in itertools.combinations([i for i in range(1,k+1)],3):
        val1 = common(i[0],i[1])
        val2 = common(val1,i[2])
        sum = sum + val2*6


    print(sum)




calculate(K)

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

char c[102][102];

void dfs(int x,int y,char z){
    if(c[x][y]!=z){
        return;
    }

    c[x][y]='.';

    
    dfs(x-1,y,z);
    
    dfs(x,y-1,z);
    dfs(x,y+1,z);
    
    dfs(x+1,y,z);
    

}

int main(){
    while(true){
        int h,w;
        cin >> h >> w;

        if(h==0&&w==0){
            break;
        }

        for(int i=1;i<=h;i++){
            for(int j=1;j<=w;j++){
                cin >> c[i][j];
            }
        }

        int ans = 0;


        for(int i=1;i<=h;i++){
            for(int j=1;j<=w;j++){
                if(c[i][j]!='.'){
                    dfs(i,j,c[i][j]);
                    ans++;
                }
            }
        }

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


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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> p(n);
  for (int i = 0; i < n; i++) cin >> p[i];
  auto q = p;
  sort(q.begin(), q.end());
  int d = 0;
  for (int i = 0; i < n; i++) if (p[i] != q[i]) d++;
  if (d <= 2) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}


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

int main(){

    size_t n, x;

    std::cin >> n >> x;
    
    std::vector<size_t> l(n + 1, 0);

    for(size_t i = 1; i <= n; i++){
        size_t tmp;
        std::cin >> tmp;
        l.at(i) = l.at(i - 1) + tmp;
    }

    std::cout << std::count_if(l.begin(), l.end(), [x](auto a){ return a <= x ? true : false; }) << std::endl;
    
    return 0;
}


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

int main() {
    int X, A, B;

    cin >> X >> A >> B;

    A -= B;

    if (A >= 0) cout << "delicious" << endl;
    else if (A >= -X) cout << "safe" << endl;
    else cout << "dangerous" << endl;

    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#define dlog(str) cout << "====" << str << endl;
#else
#define dlog(str)
#endif
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(int i = 0, i##_l = (n); i < i##_l; i++)
#define FOR(i, s, e) for(int i = s, i##_l = (e); i < i##_l; i++)
#define LLI long long int
#define _min(a,b) ((a<b)?a:b)
#define _max(a,b) ((a<b)?b:a)
#define chmax(a, b) a = _max(a, b)
#define chmin(a, b) a = _min(a, b)
#define bit(a, shift) ((a>>shift)&1))
#define pm(a) ((a)?1:-1)
#define SORT(v) sort(v.begin(),v.end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
// int 2.14E±9    lli 9.2E±18    double 1.7E±380


int main() {
    cout << fixed << setprecision(10);
    int N;
    cin >> N;//
    cout<<(int)((N + 1) / 2);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
//#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
//#include <utility>
#include <set>
//#include <map>
//#include <queue>
#include <bitset>
#include <math.h>
using namespace std ;
using ll = long long ;
using ld = long double ;
using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;

//ll mod = 1000000007 ;
//long double pie = acos(-1) ;
int n ;
vector<string> ans ;
set<string> ok ;
string yorn(bool a){if(a) return"Yes" ; return "No" ;}
string YorN(bool a){if(a) return"YES" ; return "NO" ;}
ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
void mysort(vector<string> &a){sort(a.begin(),a.end()) ;}
//void myrev(vector<long long> &a){reverse(a.begin(),a.end()) ;}

void solve(string s){
	if(s.size()==n){
		if(!ok.count(s)){
			ok.insert(s) ;
			ans.push_back(s) ;
		}
	}else{
		char c = 'a' ;
		for(int i=0;i<s.size();i++){
			if(c<s.at(i)) c = s.at(i) ;
		}
		for(int i=0;i<=c-'a'+1;i++){
			string t = s ;
			t += 'a'+i ;
			solve(t) ;
		}
	}
}

int main(){
	cin >> n ;
	if(n==1){
		cout << 'a' << endl ;
		return 0 ;
	}else if(n==2){
		cout << "aa" << endl ;
		cout << "ab" << endl ;
		return 0 ;
	}
	solve("a") ;
	mysort(ans) ;
	for(auto i:ans) cout << i << endl ;
}


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

int main(){
  int N;
  cin >> N;
  
  int ct=0;
  string s;
  
  for(int i=0;i<N;i++){
    
    cin >> s;
    if(s=="Y"){
      ct++;
      break;
    }   
  }
  
  if(ct==1) cout << "Four"<<endl;
  else cout << "Three" << endl;
  
}

Measured memory_bytes: 3536
#include <bits/stdc++.h>
using namespace std;
int main(){
    int A,B;
    cin>>A>>B;
    string S;
    cin>>S;
    for(int i=0;i<A;i++){
        if(S[i]=='-'){cout<<"No"<<endl;exit(0);}
    }
    if(S[A]!='-'){cout<<"No"<<endl;exit(0);}
    for(int i=A+1;i<A+B+1;i++){
        if(S[i]=='-'){cout<<"No"<<endl;exit(0);}
    }
    cout<<"Yes"<<endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repe(i,n) for (int i = 0; i <= (n); ++i)
#define repe1(i,n) for (int i = 0; i <= (n); ++i)
#define all(x) (x).begin(),(x).end()
#define pb(x) push_back(x)
#define eb(k,v) emplace_back(k,v)
#define ct(res) cout << res << "\n";
#define vi vector<int>
#define vl vector<ll>
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1e9;
const ll mod = 1000000007;

using Graph = vector<vector<int>>;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n; cin >> n;
    vi a(n); rep(i,n) cin >> a[i];
    int res = 0;
    int tmp = 1;
    for(int i=1; i<=n; ++i) {
        if (a[i]==a[i-1]) {
            tmp++;
        } else {
            res += tmp/2;
            tmp = 1;
        }
    }
    cout << res << "\n";
}


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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

int n, k;

int main(void) {
  // Here your code !
  scanf("%d %d", &n, &k);

  if (k == 1) {
    printf("0\n");
    return 0;
  }

  printf("%d\n", n - (k - 1) - 1);

  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int x = 0;
    int max=0;
    sc.nextLine();
    String[] input = sc.nextLine().split("");
    for(int i=0; i<input.length; i++){
      if(input[i].equals("I")){
        x++;
      }else{
        x--;
      }
      if(max<x){
        max=x;
      }
    }
    System.out.println(max);
  }
}

Measured memory_bytes: 21588
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Abc
{
    class QuestionE
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 整数配列の入力
            var nx = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();

            var n = nx[0];
            var x = nx[1];
            // 整数配列の入力
            var a = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();

            var count = 0L;

            for (int i = 0; i < n - 1; i++) {
                var y = a[i] + a[i + 1];
                var nec = y - x;

                if(nec > 0) {
                    var min = Math.Max(a[i + 1] - nec, 0);
                    var max = Math.Max(nec - a[i + 1], 0);
                    a[i + 1] = min;
                    a[i] = max;
                    count += nec;
                }
            }

            Console.WriteLine(count);

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 29404
#include <stdio.h>
#include <math.h>

#define CONS (1000000000 + 7)

int main()
{
	long long int n;
	long long int m;

	long long int i;

	unsigned long long int nm = 1;

	scanf("%lld %lld", &n, &m);

	if(n+1 == m || m+1 == n){
		for(i = 2; i <= n; i++){
			nm *= i;
			nm %= CONS;
		}
		for(i = 2; i <= m; i++){
			nm *= i;
			nm %= CONS;
		}
	}
	else if(n == m){
		for(i = 1; i <= n; i++){
			nm *= i;
			nm %= CONS;
		}

		nm = (nm * nm * 2) % CONS;
	}
	else {
		nm = 0;
	}

	printf("%lld\n", nm);

	return 0;
}

Measured memory_bytes: 128
#define _USE_MATH_DEFINES
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <clocale>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i, s, n) for(int i = (s), i##_len=(n); i < i##_len; ++i)
#define FORS(i, s, n) for(int i = (s), i##_len=(n); i <= i##_len; ++i)
#define VFOR(i, s, n) for(int i = (s); i < (n); ++i)
#define VFORS(i, s, n) for(int i = (s); i <= (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) FORS(i, 0, n)
#define VREP(i, n) VFOR(i, 0, n)
#define VREPS(i, n) VFORS(i, 0, n)
#define RFOR(i, s, n) for(int i = (s), i##_len=(n); i >= i##_len; --i)
#define RFORS(i, s, n) for(int i = (s), i##_len=(n); i > i##_len; --i)
#define RREP(i, n) RFOR(i, n, 0)
#define RREPS(i, n) RFORS(i, n, 0)
#define IREP(v, i) for(auto i = (v).begin(); i != (v).end(); ++i)
#define IRREP(v, i) for(auto i = (v).rbegin(); i != (v).rend(); ++i)
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v), greater<decltype(v[0])>())
#define SZ(x) ((int)(x).size())
#define REV(x) reverse(ALL(x))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())

using ld = long double;
using ll = long long;
using ui = unsigned int;
using ull = unsigned long long;
using Pi_i = pair<int, int>;
using Pll_ll = pair<ll, ll>;
using VB = vector<bool>;
using VC = vector<char>;
using VD = vector<double>;
using VI = vector<int>;
using VLL = vector<ll>;
using VS = vector<string>;
using VSH = vector<short>;
using VULL = vector<ull>;

const int MOD = 1000000007;
const int INF = 1000000000;
const int NIL = -1;
const double EPS = 1E-10;

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


int main(){
    int N; cin >> N;
    VI b(N), rans;
    REP(i, N) cin >> b[i];
    REP(i, N){
        RREP(j, b.size()-1){
            if(b[j] == j+1){
                rans.PB(j+1);
                b.erase(b.begin() + j);
                break;
            }
            if(!j){
                cout << -1 << endl;
                return 0;
            }
        }
    }
    IRREP(rans, itr)
        cout << *itr << "\n";
    return 0;
}


Measured memory_bytes: 256
n=int(input())
h=list(map(int,input().split()))
dp=[0]*n
dp[1]=abs(h[0]-h[1])
for i in range(n-2):
    dp[i+2]=min(dp[i+1]+abs(h[i+2]-h[i+1]),dp[i]+abs(h[i+2]-h[i]))
print(dp[-1])

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

void solve(long long N, std::vector<long long> d) {
    ll ans = 0;
    for (ll i = 0; i < N; i++) {
        for (ll j = i + 1; j < N; j++) {
            ans += d[i] * d[j];
        }
    }
    cout << ans << endl;
}

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


Measured memory_bytes: 3648
#include<bits/stdc++.h>
#define MOD 1000000007
#define md 998244353
#define INF LLONG_MAX
#define F first
#define S second
#define sz(x) (long long)x.size()
#define vi vector<int>
#define vll vector<long long>
#define vpl vector<pair<long long,long long> >
#define vpi vector<pair<int,int> >
#define pb push_back
#define debug(x) cerr<<#x<<"= "<<x<<endl
#define all(v) v.begin(),v.end()
#define TT ll test;cin>>test; while(test--)
#define rep(i,a,n) for(ll i=a;i<(long long)n;++i)
#define repr(i,n,a) for(ll i=n;i>(long long)a;--i)
#define endl '\n'
#define MAXN 200005
typedef long long ll;
typedef long double ld;
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    ll a,b,c,d;
    cin>> a>> b >> c >>d;
    ll res = -INF;
    res=max({a*c,a*d,b*c,b*d});
    cout<<res;

    

    return 0;
}


Measured memory_bytes: 3648
#include<iostream>
using namespace std;
int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (a > b && a > c){
		cout << "A";
		}
	if (b > c && b > a) {
		cout << "B";
	}
	if (c > a && c > b) {
		cout << "C";
	}
	cout << endl;
}


Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
#define all(c) (c).begin(),(c).end()
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define iter(c) __typeof((c).begin())
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
#define pb(a) push_back(a)
#define pr(a) cout<<(a)<<endl
#define PR(a,b) cout<<(a)<<" "<<(b)<<endl
#define R cin>>
#define F first
#define S second
#define ll long long
bool check(int n,int m,int x,int y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<60,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

int main() {
  int n,h,w;
  cin >> n >> h >> w;
  int d1[300001],d2[300001];
  memset(d1,0,sizeof(d1));
  memset(d2,0,sizeof(d2));
  rep(i,n) {
    int x,y,z;
    cin >> x >> y >> z;
    d1[x+100000-z]++;
    d1[x+100000+z]--;
    d2[y+100000-z]++;
    d2[y+100000+z]--;
  }
  bool ck=true,ck2=true;
  REP(i,1,300000) {
    d1[i]+=d1[i-1];
    d2[i]+=d2[i-1];
    if(i>=100000) {
      int j=i-100000;
      if(!d1[i] && j<h) ck=false;
      if(!d2[i] && j<w) ck2=false;
    }
  }
  if(ck||ck2) pr("Yes");
  else pr("No");
  return 0;
}


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

using namespace std;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl;
#define OK(ok) cout << (ok ? "Yes" : "No") << endl;
typedef long long ll;

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail) {
  cin >> head; CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

const int INF = 1e9 + 1;
const int MOD = 1e9 + 7;
const int MAX_N = 1e5 + 1;

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

  SCIN(S);
  cout << "2018";
  FOR(i, 4, S.size()) {
    cout << S[i];
  }
  cout << endl;

  return 0;
}



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

int main() {
    
    int h, a;
    int count=0;
    
    cin >> h >> a;
    
    
    while(1){
        h -= a;
        count++;
        if(h <= 0) break;
    }
    
    cout << count << endl;
    
    return 0;
}




Measured memory_bytes: 256
mod = 1000000007

def comb(n, k):
    patterns = 1
    for i in range(k):
        patterns *= n - i
        patterns *= pow(i + 1, mod - 2, mod)
        patterns %= mod
    return patterns

n, a, b = map(int, input().split())
print((pow(2, n, mod) - 1 - comb(n, a) - comb(n, b) + 2 * mod) % mod)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  
  if ((A + B) > (C + D)) {
    cout << "Left" << endl;
  }
  else if ((A + B) == (C + D)){
    cout << "Balanced" << endl;
  }
  else{
    cout << "Right" << endl;
  }
}

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

int main(){
    int n, c; cin >> n;
    string s;
    list<int> l;
    for(int i=0; i<n; i++){
        cin >> s;
        if(s =="insert"){
            cin >> c;
            l.push_front(c);
        }else if(s=="delete"){
            cin >> c;
            for (list<int>::iterator it=l.begin(); it!=l.end(); it++) {
                if( (*it) == c){
                    l.erase(it);
                    break;
                }
            }
        }else if(s=="deleteFirst"){
            l.pop_front();
        }else{
            l.pop_back();
        }
    }
    
    for(list<int>::iterator i=l.begin(); i!=l.end(); ){
    	cout << *i;
    	if(++i==l.end()) cout << endl;
    	else cout << " ";
    }
    
    return 0;
}


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

int main(){
  int a, b, c;
  cin >> a >> b >> c;
  if ((a == b && b != c) || (a != b && b == c) || (a == c && b != c)) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, c) for(long long i=0; i<(long long)c; i++)
#define INF 1000000000000000000
int main() {
	long long ans;
	int n;
	cin>>n;
	vector< long long>a(n);
	ans=1;
	rep(i,n){
		cin >> a[i];
		if (a[i]==0){
			ans=0;
			cout <<ans<<endl;
			return 0;
		}
	}
	rep(i,n){
		if (ans >= LONG_MAX/a[i]){
			ans=-1;
			break;
		}
		ans*=a[i];
		if (ans > INF){
			ans=-1;
			break;
		}
	}
	cout <<ans<<endl;
	return 0;
}


Measured memory_bytes: 4048
#include <stdio.h> 

int main(void)
{
	int a,b,c;

	scanf("%d %d %d",&a,&b,&c);

	if((a < b) && (b < c))
	{
		printf("Yes\n");
	}
	else
	{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 580
n = int(input())
h = list(map(int, input().split()))
for i in range(1, n):
    c = h[-i] - h[-(i + 1)]
    if c >= 0:
        continue
    if c == -1:
        h[-(i + 1)] -= 1
    else:
        print('No')
        break
else:
    print('Yes')


Measured memory_bytes: 20532
"use strict";
function Main(input) {
    let lines = input.split("\n");
    let xyzk = lines.shift().split(/\s/).map((v) => v - 0);
    let X = xyzk[0], Y = xyzk[1], Z = xyzk[2], K = xyzk[3];
    let A = lines.shift().split(/\s/).map((v) => v - 0).sort((a, b) => b - a);
    let B = lines.shift().split(/\s/).map((v) => v - 0).sort((a, b) => b - a);
    let C = lines.shift().split(/\s/).map((v) => v - 0).sort((a, b) => b - a);
    let abcL = Math.min(K, X * Y * X);
    let abc = new Array(abcL);
    let i = 0;
    for (let x = 0; x < X; x++) {
        for (let y = 0; y < Y; y++) {
            if ((x+1)*(y+1) > K) break;
            for (let z = 0; z < Y; z++) {
                if ((x+1)*(y+1)*(z+1) > K) break;
                abc[i++] = A[x] + B[y] + C[z];
            }
        }
    }
    abc.sort((a, b) => b - a);
    for (let n = 0; n < K; n++) {
        console.log(abc[n]);
    }
}
if (typeof window === 'undefined') Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 41644
#include <bits/stdc++.h>
#define ll long long

using namespace std;

bool IsWinnig(ll K);

ll n,k;
ll a[110];
ll Dp[100100];

int main()
{
    memset(Dp,-1,sizeof(Dp));

    cin>>n>>k;

    for(ll i=0;i<n;i++) scanf("%I64d",a+i);

    cout<<( IsWinnig(k) ? "First" : "Second" );
}

bool IsWinnig(ll K)
{
    if(Dp[K]+1) return Dp[K];

    for(ll i=0;i<n;i++)
        if(K>=a[i]&&!IsWinnig(K-a[i]))
            return Dp[K] = true;

    return Dp[K] = false;
}


Measured memory_bytes: 4096
// Aizu 1148: Analyzing Login/Logout Records
// 2017.9.16 bal4u@uu

#include <stdio.h>

typedef struct { int t, pc, m, s; } R;
R rd[1005];

int main()
{
	int n, m, r, q, i, j, ts, te, t, ans, cnt;

	while (scanf("%d%d", &n, &m) && n) {
		scanf("%d", &r); 
		for (i = 0; i < r; i++) scanf("%d%d%d%d", &rd[i].t, &rd[i].pc, &rd[i].m, &rd[i].s);
		scanf("%d", &q); 
		for (i = 0; i < q; i++) {
			scanf("%d%d%d", &ts, &te, &m);
			for (ans = t = cnt = 0, j = 0; j < r; j++) {
				if (rd[j].t >= te) { if (t > 0) ans += te - t; break; } 
				if (rd[j].m != m) continue;
				if (rd[j].s) {
					cnt++; if (t == 0) { if (rd[j].t < ts) t = ts; else t = rd[j].t; }
				} else {   // lg[j].s == 0
					if (--cnt == 0) {
						if (rd[j].t > ts && t > 0) ans += rd[j].t - t;
						t = 0;
					}
				}
			}
			printf("%d\n", ans);
		}
	}
	return 0;
}

Measured memory_bytes: 1660
import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.System.*;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

    static void solve() throws Exception {
        long n = scanLong(), m = scanLong();
        long a = n % m;
        long b = Math.abs(a - m);
        if (n <= a && n <= b) {
            out.print(n);
        } else if (a <= b && a <= n) {
            out.print(a);
        } else {
            out.print(b);
        }

    }

    static int scanInt() throws IOException {
        return parseInt(scanString());
    }

    static long scanLong() throws IOException {
        return parseLong(scanString());
    }

    static String scanString() throws IOException {
        while (tok == null || !tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine());
        }
        return tok.nextToken();
    }

    static BufferedReader in;
    static PrintWriter out;
    static StringTokenizer tok;

    public static void main(String[] args) {
        try {
            in = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);
            solve();
            in.close();
            out.close();
        }
        catch (Throwable e) {
            e.printStackTrace();
            exit(1);
        }
    }
}

Measured memory_bytes: 22868
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		long M_hp = sc.nextLong();
		long count = 1;
		long attack = 1;
		int flg = 0;
		if(M_hp == 1) {
		}else {

			for(;;) {
				M_hp = M_hp/2;
				if(M_hp < 2) {
					count = count*2;
					attack = attack + count;
					break;
				}else {
					count = count*2;
					attack = attack + count;
				}

			}
		}
			System.out.println(attack);
		}
	}


Measured memory_bytes: 23252
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define ld long double
using namespace std;
const int maxn = 3100;
ld dp[maxn][maxn], p[maxn];
ll n;

int main() {
    cin>>n;
    for(int i=1;i<=n;i++) {
        cin>>p[i];
    }

    // dp[i][j] -> probability to get j heads from the first i coins
    dp[0][0] = 1.0;
    for(int i=1;i<=n;i++) {
        for(int j=0;j<=i;j++) {
            dp[i][j] = dp[i-1][j] * (1.0 - p[i]);
            if(j>=1)
                dp[i][j] += dp[i-1][j-1] * p[i];
        }
    }

    ld result = 0.0;
    for(int i=1;i<=n;i++) {
        if(i > n-i) {
            result += dp[n][i];
        }
    }
    cout<<setprecision(10)<<fixed<<result<<"\n";
    return 0;
}


Measured memory_bytes: 143872
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<tuple>
#define int long long
using namespace std;

signed main() {
	string S;
	cin >> S;
	int answer = 0;
	for(int i = 0;i < S.size() - 1;i++) {
		if(S.at(i) != S.at(i + 1)) {
			answer++;
		}
	}
	cout << answer << endl;
}

Measured memory_bytes: 512
import sys
import math
from collections import defaultdict

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N,num):
    if N<=0:
        return [[]]*num
    elif num==1:
        return [I() for _ in range(N)]
    else:
        read_all = [tuple(II()) for _ in range(N)]
        return map(list, zip(*read_all))

#################

def solve(n):
    ans = 0
    for i in range(1, int(n**0.5)+1):
        if n%i == 0:
            if n//i > i+1:
                ans += n//i-1
    return ans

N = I()
print(solve(N))

Measured memory_bytes: 38768
import java.util.Scanner;
public class Main{
	public void solve(){
		Scanner sc=new Scanner(System.in);
		int S=sc.nextInt();
		
		int h=S/3600;
		int m=(S-3600*h)/60;
		int s=S-3600*h-60*m;
		
		System.out.println(h+":"+m+":"+s);
	}
	public static void main(String[] args){
		Main obj=new Main();
		obj.solve();
	}
}

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

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
#define rrep(i, m, n) for(int (i)=(m); (i)<(n);  (i)++)
#define erep(i, m, n) for(int (i)=(m); (i)<=(n); (i)++)
#define  rep(i, n)    for(int (i)=0; (i)<(n);  (i)++)
#define rrev(i, m, n) for(int (i)=(n)-1; (i)>=(m); (i)--)
#define erev(i, m, n) for(int (i)=(n); (i)>=(m); (i)--)
#define  rev(i, n)    for(int (i)=(n)-1; (i)>=0; (i)--)
#define vrep(i, c)    for(__typeof((c).begin())i=(c).begin(); i!=(c).end(); i++)
#define  ALL(v)       (v).begin(), (v).end()
#define pb            push_back
#define mp            make_pair
template<class T, class S> inline bool minup(T& m, const S x){ return m>(T)x ? (m=(T)x, true) : false; }
template<class T, class S> inline bool maxup(T& m, const S x){ return m<(T)x ? (m=(T)x, true) : false; }

static const int    INF = 1000000000;
static const ll     MOD = 1000000007LL;
static const double EPS = 1E-10;

int s[4];
int res;

int main()
{
  rep(i, 4) cin >> s[i];
  rep(i, 4) res += s[i];
  cout << res / 60 << endl;
  cout << res % 60 << endl;

  return 0;
}

Measured memory_bytes: 1160