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

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

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


//-----CODE------//


void solve_part_problem(void)
{
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  int flg = 1;
  if(b > a)
  {
    cout<<"No"<<endl;
    return;
  }
  if(b <= a and b > d)
  {
    cout<<"No"<<endl;
    return;
  }
  if(b <= a and b <= d and c >= b)
  {
    cout<<"Yes"<<endl;
    return;
  }

  int g = gcd(b,d);
  int x = b - g +(a%g);
  if(x > c)
  {
    cout<<"No"<<endl;
  }
  else
  {
    cout<<"Yes"<<endl;
  }

  
  // for (int i = 0; i < 1e6; i++)
  // {
  //   if(s < b)
  //   {
  //     flg = 0;
  //     break;
  //   }
  //   s %= b;
  //   if(s <= c)
  //   {
  //     s += d;
  //   }
  // }
  // if(flg)
  // {
  //   cout<<"Yes"<<endl;
  // }
  // else
  // {
  //   cout<<"No"<<endl;
  // }
  
  
  return;
}
void solve(void)
{
  int Q;cin>>Q;
  for(int q = 0; q < Q; q++)
  {
    solve_part_problem();
  }
  return;
}
int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

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

  return 0;
}


Measured memory_bytes: 3636
n, w = gets.split.map(&:to_i)
h = Hash.new{|hash,key| hash[key] = []}

n.times do
    k, v = gets.split.map(&:to_i)
    h[k] << v
end

h = h.map {|k,v| [k, v.sort_by!{|ee| -ee}]}
h.map! do |k,v| 
    (v.size - 1).times {|i| v[i+1] += v[i]}
    v << 0
    [k, v]
end
h += [[0, [0]]] * 3

ans = 0
(h[0][1].size + 1).times do |i|
    w_sum0 = h[0][0] * i
    v_sum0 = h[0][1][i-1]
    break if w_sum0 > w

    (h[1][1].size + 1).times do |j|
        w_sum1 = w_sum0 + h[1][0] * j
        v_sum1 = v_sum0 + h[1][1][j-1]
        break if w_sum1 > w

        (h[2][1].size + 1).times do |x|
            w_sum2 = w_sum1 + h[2][0] * x
            v_sum2 = v_sum1 + h[2][1][x-1]
            break if w_sum2 > w

            (h[3][1].size + 1).times do |y|
                w_sum3 = w_sum2 + h[3][0] * y
                v_sum3 = v_sum2 + h[3][1][y-1]
                break if w_sum3 > w
                ans = v_sum3 if ans < v_sum3
            end
        end
    end
end

p ans

Measured memory_bytes: 14324
int a[]={0,1,9,30,76,141,267,400,624,885,1249,1590,2208,2689,3411,4248,5248,6081,7485,8530,10248,11889,13687,15228,17988,20053,22569,25242,28588,31053,35463,38284,42540,46581,50893,55362,61824,65857,71247,76884,84388,89349,97881,103342,111528,120141,128047,134580,146316,154177,164817,174438,185836,194157,207927,218812,233268,245277,257857,268182,288216,299257,313635,330204,347836,362973,383709,397042,416448,434025,456967,471948,499740,515581,536073,559758,583960,604833,633651,652216,683712,709065,734233,754734,793188,818917,846603,874512,909496,933081,977145,1006126,1041504,1073385,1106467,1138536,1187112,1215145,1255101,1295142,1342852,1373253,1422195,1453816,1502376,1553361,1595437,1629570,1691292,1726717,1782111,1827492,1887772,1925853,1986837,2033674,2089776,2145333,2197483,2246640,2332104,2379085,2434833,2490534,2554600,2609625,2693919,2742052,2813988,2875245,2952085,3003306,3096024,3157249,3224511,3306240,3388576,3444609,3533637,3591322,3693924,3767085,3842623,3912324,4027884,4102093,4181949,4270422,4361548,4427853,4548003,4616104,4718640,4812789,4918561,5003286,5131848,5205481,5299011,5392008,5521384,5610705,5739009,5818390,5930196,6052893,6156139,6239472,6402720,6493681,6623853,6741078,6864016,6953457,7094451,7215016,7359936,7475145,7593865,7689630,7886244,7984165,8130747,8253888,8403448,8523897,8684853,8802826,8949612,9105537,9267595,9376656,9574704,9686065,9827097,9997134,10174780,10290813,10493367,10611772,10813692};
main(i) {
  scanf("%d",&i);
  printf("%d",a[i]); 
}

Measured memory_bytes: 1712
import math
sqrt3 = math.sqrt(3.0)

def koch_curve(n, i, pt1, pt2, pt_array):
    if i > n:
        return
    pt1x, pt1y = pt1
    pt2x, pt2y = pt2
    pts = (2/3 * pt1x + 1/3 * pt2x, 2/3 * pt1y + 1/3 * pt2y)
    ptt = (1/3 * pt1x + 2/3 * pt2x, 1/3 * pt1y + 2/3 * pt2y)
    ptx = ptt[0] - pts[0]
    pty = ptt[1] - pts[1]
    ptu = (1/2 * (ptx - sqrt3 * pty) + pts[0], 1/2 * (sqrt3 * ptx + pty) + pts[1])

    koch_curve(n, i+1, pt1, pts, pt_array)
    pt_array.append(pts)
    koch_curve(n, i+1, pts, ptu, pt_array)
    pt_array.append(ptu)
    koch_curve(n, i+1, ptu, ptt, pt_array)
    pt_array.append(ptt)
    koch_curve(n, i+1, ptt, pt2, pt_array)
    return

def main():
    n = int(input())
    pt_array = []
    begin = (0.0, 0.0)
    end = (100.0, 0.0)
    pt_array.append(begin)
    koch_curve(n, 1, begin, end, pt_array)
    pt_array.append(end)
    for pt in pt_array:
        print("{:.6f} {:.6f}".format(pt[0], pt[1]))

main()


Measured memory_bytes: 6256
n,m = map(int, input().split())
A = [input() for _ in range(n)]
B = [input() for _ in range(m)]

for r in range(n-m+1):
    for c in range(n-m+1):
        X = []
        for a in A[r:r+m]:
            X.append(a[c:c+m])
        if X == B:
            print('Yes')
            exit()
print('No')

Measured memory_bytes: 3060
n = gets.to_i
aryx = []
aryy = []
n.times do |i|
  a,b = gets.strip.split.map(&:to_i)
  aryx[i] = a-b
  aryy[i] = a+b
end
aryx.sort!
aryy.sort!
puts [aryx[n-1]-aryx[0],aryy[n-1]-aryy[0]].max

Measured memory_bytes: 19824
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = scan.nextInt();
		int[] d = new int[101];
		int result = 0;
		if (a!=b && b!=c && c!=a) {
			result = 3;
		}
		if (a==b && b==c) {
			result = 1;
		}
		if ((a==b && b!=c) || (a!=b && b==c) || (c==a && a!=b)) {
			result = 2;
		}

		System.out.println(result);
	}

}


Measured memory_bytes: 21972
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <cmath>
#include <cassert>
using namespace std;

int main(){
    int N;
    cin >> N;
    vector<int> H(N);
    for(int i=0; i<N; i++)
        cin >> H[i];
    for(int i=1; i<N; i++){
        if(H[i-1] <= H[i]) continue;
        else if(H[i] == H[i-1]-1) H[i]++;
        else{
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 640
// 2013 TT 021 Div 2 
#include <iostream>
#include <string>
 
using namespace std;
 
int main(void) {
  int w, h;
  string prgrm;
  int num;
  int px, py;
  int angle;
  int dx[4] = {0, 1, 0, -1};
  int dy[4] = {1, 0, -1, 0};
   
 
  for(;;) {
    cin >> w >> h;
    if(w == 0 && h == 0) {
      break;
    }
 
    w--; h--;
    px = 0; py = 0; angle = 0;
     
    for(;;) {
      cin >> prgrm;
      if(prgrm == "RIGHT") {
    angle++;
    if(angle == 4) angle = 0;
    continue;
     
      } else if(prgrm == "LEFT") {
    angle--;
    if(angle == -1) angle = 3;
    continue;
 
      } else if(prgrm == "STOP") {
    cout << px+1 << " " << py+1 << endl;
    break;
      }
 
      cin >> num;
       
      if(prgrm == "FORWARD") {
    px += dx[angle]*num;
    py += dy[angle]*num;
    if(px < 0) px = 0;
    if(py < 0) py = 0;
    if(px > w) px = w;
    if(py > h) py = h;
     
      } else if(prgrm == "BACKWARD") {
    px -= dx[angle]*num;
    py -= dy[angle]*num;
    if(px < 0) px = 0;
    if(py < 0) py = 0;
    if(px > w) px = w;
    if(py > h) py = h;
      }
    }
     
  }
 
  return 0;
}

Measured memory_bytes: 1208
#include <stdio.h>
#include <string.h>

int main(int argc, const char * argv[]) {
    char str[1001], op[8], tmp[1001], p[1002];
    int a, b, q, x;
    scanf("%s", str);
    scanf("%d", &q);
    for(int i=0; i<q; i++){
        scanf("%s", op);
        scanf("%d %d", &a, &b);
        if(strcmp(op, "print")==0){
            for(int i=a; i<=b; i++){
                printf("%c", str[i]);
            }
            printf("\n");
        }else if(strcmp(op, "reverse")==0){
            strcpy(tmp, str);
            x=a;
            for(int i=b; i>=a; i--){
                str[x] = tmp[i];
                x++;
            }
        }else if(strcmp(op, "replace")==0){
            scanf("%s", p);
            strncpy(&str[a], p, b-a+1);
        }
    }
    return 0;
}



Measured memory_bytes: 2112
#include <iostream>
#include <vector>
#include <queue>
#include <string.h>
#include <math.h>
using namespace std;
typedef long long ll;

int main(void){
    int a, b, c, d, f;
    double e;
    cin >> a >> b >> c >> d >> e >> f;
    
    e+=0.0;
    e = 100 * e / (100 + e);
    bool water[35];
    for (int i = 0; i <= 30; i++) water[i] = false;
    for (int i = 0; i <= 30; i++) {
        for (int j = 0; j <= 30; j++) {
            if (a*i + b*j <= 30) water[a*i + b*j] = true;
        }
    }
    
    bool sugar[3000];
    for (int i = 0; i <= 3000; i++) sugar[i] = false;
    for (int i = 0; i <= 3000; i++) {
        for (int j = 0; j <= 3000; j++) {
            if (c*i + d*j <= 3000) sugar[c*i + d*j] = true;
        }
    }
    
    double mx = 0.0;
    int mx_s=0, mx_w=a;
    for (int i = 0; i <= 30; i++) {
        for (int j = 0; j <= 3000; j++) {
            if (water[i] && sugar[j] && 100*i + j <= f && double(100*j) /double(100*i + j) <= e) {
                if (mx < double(100*j) /double(100*i + j)) {
                    mx = double(100*j) /double(100*i + j);
                    mx_s = j;  mx_w = i;
                }
            }
        }
    }
    
    cout << mx_w * 100 + mx_s<< " " << mx_s << endl;
    //cout << mx << endl;
}


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

#define REP(i, n ,N) for(int i = (n); i < (N); i++)
#define RREP(i, n ,N) for(ll i = (N-1); i >= 0; i--)
#define p(s) cout<<(s)<<endl
#define p2(a, b) cout<<(a)<<" "<<(b)<<endl
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
ll inf = 1e18;

int N;
string S;
int ans=0;
bool C(int mid){//ここに条件を書く
	unordered_map<string, int> mp; // string, r_pos
	//lbが更新される不等式を書く
	REP(i,0,N-mid+1){
		string s = S.substr(i, mid);
		if(mp.count(s) > 0 && mp[s] < i){
			return true;
		}else if(mp.count(s) == 0){
			mp[s] = i + mid - 1;
		}
	}
    return false;
}


int Nibutan(int lb, int ub){
    while(ub-lb>1){
        int mid=(lb+ub)/2;
        if(C(mid)) lb=mid;
        else ub=mid;
    }
    return lb;
}
int main(){
	cin >> N >> S;
	ans = Nibutan(0, N + (N%2==0));
	p(ans);

	return 0;
}

Measured memory_bytes: 6668
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
const ll INF = 1000000000000LL;

ll n, m, s[15], d[101], dp[1<<15];

ll labs(ll a) { return a < 0 ? -a : a; }

int main() {
  while (scanf("%lld%lld", &n, &m), n) {
    ll all_sum = 0;
    for (ll i = 0; i < n; i++) scanf("%lld", &s[i]), all_sum += s[i];
    for (ll i = 0; i < m; i++) scanf("%lld", &d[i]);
    sort(d, d+m);
    d[m] = INF;
    for (ll i = 0; i < (1 << n); i++) dp[i] = INF;
    dp[0] = 0;
    for (ll counter = 0; counter < n; counter++) {
      for (ll x = 0; x < (1 << n); x++) {
        for (ll z = 0; z < n; z++) {
          ll y = 1 << z;
          if (x & y) continue;
          ll sum = 0, s1 = 0, s2 = 0;
          for (ll i = 0; i < n; i++) if (x & (1 << i)) s1 += s[i];
          s2 = s1 + s[z];
          ll num = lower_bound(d, d+m+1, s1) - d;
          for (ll i = num; d[i] < s2; i++) {
            sum += min(labs(d[i] - s1), labs(s2 - d[i]));
          }
          dp[x|y] = min(dp[x|y], dp[x] + sum);
        }
      }
    }
    ll ans = dp[(1 << n) - 1];
    for (ll i = 0; i < m; i++) if (d[i] > all_sum) ans += d[i] - all_sum;
    printf("%lld\n", ans);
  }
}




Measured memory_bytes: 3060
#include <iostream>
#include <string>
using namespace std;
int main()
{
    string w;
    int c[26]={0};;
    cin >> w;
    for(int i = 0; i < w.length(); i++) {
        c[(int)w[i]-97]++;
    }
    bool flag = true;
    for(int i = 0; i < 26; i++) {
        if(c[i]%2!=0)
            flag = false;
    }
    cout << (flag ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 256
let matrix_from_coord_tuples tuples n =
  let rec inner tuples array = match tuples with
    | [] -> array
    | (s, e)::rest ->
       array.(s).(e) <- array.(s).(e) + 1;
       inner rest array
  in
  inner tuples @@ Array.make_matrix (n+1) (n+1) 0

let x_axis_accum_over_matrix matrix =
  let width = Array.length matrix.(0) in
  let rec inner matrix x y width = match y with
    | y when y = width ->
       matrix
    | _ ->
       matrix.(x).(y) <- matrix.(x).(y-1) + matrix.(x).(y);
       inner matrix x (y+1) width 
  in
  for x = 0 to (Array.length matrix - 1) do
    ignore @@ inner matrix x 1 width
  done;
  matrix

let make_list f t step =
  let rec make_list_inner c t lst =
    if c >= t then lst else make_list_inner (c+step) t (c::lst)
  in
  List.rev (make_list_inner f t [])

let sum_in_rectangle matrix from_coord to_coord =
  let from_x, from_y = from_coord and
      to_x, to_y = to_coord in
  let y_sums = List.map (fun x -> matrix.(x).(to_y) - matrix.(x).(from_y-1)) @@ make_list from_x (to_x+1) 1 in
(*  for i = 0 to (List.length y_sums - 1) do
    Printf.printf "%d " (List.nth y_sums i);
  done;
  print_newline ();*)
  List.fold_left (fun x y -> x + y) 0 y_sums

let solve num_cities trains queries =
  let train_accum_matrix = x_axis_accum_over_matrix (matrix_from_coord_tuples trains num_cities) in
  List.iter (fun (s, e) ->
      begin
        Printf.printf "%d\n" @@ sum_in_rectangle train_accum_matrix (s, s) (e, e)
      end
    ) queries       
       
let read_list_of_int_tuple n =
  let rec read_list_of_int_inner n lst = match n with
    | 0 -> List.rev lst
    | _ ->
       try let ans = (Scanf.scanf "%d %d\n" (fun x y->x,y)) in
           read_list_of_int_inner (n-1) (ans::lst)
       with End_of_file ->
         List.rev lst
  in
  read_list_of_int_inner n []

let () =
  let rec read () =
    try let num_cities, num_trains, num_queries = (Scanf.scanf "%d %d %d\n" (fun x y z -> x, y, z) ) in
        let trains = read_list_of_int_tuple num_trains
        and queries = read_list_of_int_tuple num_queries in
        solve num_cities trains queries
    with End_of_file -> ()
  in
  read ()
;;


Measured memory_bytes: 34560
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
typedef long long llong;
const int MOD=1000000007;

int main(int argc, char**argv){
    string s, t;
    cin >> s >> t;
    vector<char> ss(s.size());
    vector<char> tt(t.size());
    for (int i = 0; i < s.size(); i++){
        ss[i] = s[i];
    }
    for (int i = 0; i < t.size(); i++){
        tt[i] = t[i];
    }
    sort(ss.begin(), ss.end());
    sort(tt.begin(), tt.end());
    reverse(tt.begin(), tt.end());

    for (int i = 0; i < s.size(); i++){
        s[i] = ss[i];
    }
    for (int i = 0; i < t.size(); i++){
        t[i] = tt[i];
    }

    if (s < t) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}





Measured memory_bytes: 256
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include<algorithm>
#include<iostream>
#include<cstring>
#include<fstream>
#include<bitset>
#include<cstdio>
#include<string>
#include<vector>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#include<set>
#define INF 0X3F3F3F3F
#define N 200005
#define M 200005
#define LL long long
#define FF(i, a, b) for(int i = a; i <= b; ++i)
#define RR(i, a, b) for(int i = a; i >= b; --i)
#define FJ(i, a, b) for(int i = a; i < b; ++i)
#define SC(x) scanf("%d", &x)
#define SCC(x, y) scanf("%d%d", &x, &y)
#define SCCC(x, y, z) scanf("%d%d%d", &x, &y, &z)
#define SS(x) scanf("%s", x)
#define PR(x) printf("%d\n", x)
#define CL(a, x) memset(a, x, sizeof(a))
#define _P fd[rt]
#define _L fd[rt << 1]
#define _R fd[rt << 1 | 1]
#define MID int mid = ((l + r) >> 1)
#define lson rt<<1 ,l, mid
#define rson rt<<1 | 1, mid + 1, r
#define VI vector<int>
#define PII pair<int, int>
#define PLL pair<long long, long long>
#define MP make_pair
#define PB push_back
#define IN freopen("in.txt", "r", stdin)
#define OUT freopen("out.txt", "w", stdout)
using namespace std;
const int MOD = 1000000007;
const double PI = acos(-1.0);
const double EPS = 1e-8;
inline void II(int &n){char ch = getchar(); n = 0; bool t = 0;
for(; ch < '0'; ch = getchar()) if(ch == '-') t = 1;
for(; ch >= '0'; n = n * 10 + ch - '0', ch = getchar()); if(t) n =- n;}
inline void OO(int a){if(a < 0) {putchar('-'); a = -a;}
if(a >= 10) OO(a / 10); putchar(a % 10 + '0');}
inline int sgn(double x){return (x > EPS) - (x < -EPS);}
//struct EE{int v, w, nx;}E[M * 2 + N * 2]; int hd[N], EN;
//void init_edge(int num){EN = 0; memset(hd, -1, (num + 2) << 2);}
//void add_edge(int u, int v, int w){
//    E[EN].w = w; E[EN].v = v; E[EN].nx = hd[u]; hd[u] = EN++;
//    E[EN].w = w; E[EN].v = u; E[EN].nx = hd[v]; hd[v] = EN++;
//}
//const int dir[4][2] = {{-1, 0}, {0, -1}, {0, 1}, {1, 0}};
int n, a[30];
char s[N];
int main(){
   // IN;
    SS(s);
    int len = strlen(s);
    FF(i, 0, len - 1) ++a[s[i] - 'a'];
    LL ans = 1LL * (1 + len) * len / 2 + 1;
    FF(i, 0, 25) ans -= 1LL * a[i] * (a[i] - 1) / 2;
    cout << ans - len<< endl;
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#include<cmath>
#define N 100005
#define A 1000005
#define MOD 998244353 //1000000007 // //100000000
#define INF 1000000000000000000
#define ll long long
//#define M_PI 3.141592653589793238463

using namespace std;

#define pii pair<ll, ll>
#define piii pair<ll, pii>
#define ft first
#define sd second
#define pb push_back
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n-1; i >= 0; i--)
#define itr(it, x) for(auto it = x.begin(); it != x.end(); it++)
#define mem(a, b) memset(a, (ll)b, sizeof(a))
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define edge(v, x, y) v[x].pb(y); v[y].pb(x);
#define popcount __builtin_popcount
#define ANS(s) {cout << s << "\n"; return;}

//~~~~~~fancy print~~~~~~~//
#define printpii(a) cout << a.ft << " " << a.sd << endl;
#define printpiii(a) cout << a.ft << " " << a.sd.ft << " " << a.sd.sd << endl;
#define print(a, n) rep(i, n) cout << a[i] << " "; cout << endl;
#define printv(v) for(auto x: v)cout << x << " "; cout << endl;
#define printm(a, n, m) rep(i, n) { rep(j, m) cout << a[i][j] << "\t"; cout << endl;}

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

void fast(){ios_base::sync_with_stdio(false);cin.tie(0);cout << setprecision(12) << fixed;}

bool cmp(pii a, pii b){
    if(a.ft == b.ft) return a.sd < b.sd;
    return a.ft > b.ft;
}
void solve(){
    ll a, b, m;
    cin >> a >> b >> m;
    ll aa[a], bb[b];
    rep(i, a)cin >> aa[i];
    rep(i, b) cin >> bb[i];
    ll kk = INF;
    rep(i, m)
    {
        ll x, y, c;
        cin >> x >> y >> c; x--, y--;
        kk = min(kk, aa[x] + bb[y] - c);
    }
    kk = min(kk, (ll) (*min_element(aa, aa+a) + *min_element(bb, bb+b)));
    cout << kk;
}
main(){
    fast();
    ll t = 1; //cin >> t;
    while(t--){
        solve();
    }
}


Measured memory_bytes: 1792
//  Created by conan1024hao in 2019.
//  Copyright © 2019 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 10e8
#define INF 10e16
#define MOD 1000000007
#define mod 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
//using Int=int_fast64_t;
typedef long long int ll;
typedef pair<ll,ll>Pll;
typedef pair<int,int>Pin;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[8]={-1,0,1,0,1,1,-1,-1};
int dy[8]={0,-1,0,1,1,-1,1,-1};
char dir[4]={'u','l','d','r'};
ll cmp1(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}
//--------------------------------------------------------------------------
int n,k;
vector<int>ab[100001];
ll used=2;
ll ans;
bool color[100001];
void dfs(int x){

    color[x]=1;
    bool abc=1;
    ll minus=0;
    //cout<<ans<<endl;
    for(int i=0;i<siz(ab[x]);i++){
        if(color[ab[x][i]])continue;
        if(x==0)used=1;
        else used=2;
        if(k-used-minus<0){
            ans=0;
        }
        ans*=(k-used-minus)%MOD;
        ans%=MOD;
        dfs(ab[x][i]);
        minus++;
        ans%=MOD;
        abc=0;
        
    }
    if(x==0)used=1;
    else used=2;
    
    ans%=MOD;
    
}
//---------------------------------------------------------------------------
int main(){//問題をちゃんと見ろ!!!!!!!!!!!!!!!!!      llか??????????        memset()!!!!!!!!!!!!       ペナを減らせ!!!!!!!!!!!!!
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    memset(color, 0, sizeof(color));
    cin>>n>>k;
    ans=k;

    for(int i=0;i<n-1;i++){
        int a,b;cin>>a>>b;
        a--;b--;
        ab[a].pb(b);
        ab[b].pb(a);
    }
    
    dfs(0);
    cout<<ans%MOD<<endl;
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------




Measured memory_bytes: 9344
import copy

h, w = map(int , input().split() )

board = [input() for _ in range(h)]

left = [ [0]*w for _ in range(h)] 
right = copy.deepcopy(left )        #いくつ右のマスを照らせるか
down = copy.deepcopy(left)
up = copy.deepcopy(left)



for hi in range(h):
    for wi in range(w):

        if board[hi][wi] == '.':
            left[hi][wi] = 1
            up[hi][wi] = 1

            if 1 <= wi:
                left[hi][wi] += left[hi][wi-1]

            if 1 <= hi:
                up[hi][wi] += up[hi-1][wi]


        if board[hi][w-wi-1] =='.':
            right[hi][w-wi-1] = 1

            if 1<=wi:
                right[hi][w-wi-1] += right[hi][w-wi] 

        if board[h-hi-1][wi] == '.':
            down[h-hi-1][wi] = 1

            if 1 <= hi:
                down[h-hi-1][wi] += down[h-hi][wi]


def dbcheck():
    print()
    tag = ["r","l","d","u"]
    for t,x in zip(tag,[right,left,down,up]):
        print(t)
        for row in x:
            print(row)
        print()


#dbcheck()

ans = 0
for i in range(h):
    for j in range(w):
        t = right[i][j] + left[i][j] + up[i][j] + down[i][j]
        t -= 3
        ans = max(ans,t)

print(ans)

Measured memory_bytes: 184196
#define _USE_MATH_DEFINES
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>

using namespace std;

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


int main(){
	int v,n;
	int sum=0;
	double avr=0;
	double idx=0;
	while(~scanf("%d,%d",&v,&n)){
		sum += v*n;
		avr += n;
		idx++;
	}

	cout << sum << endl;
	double res = avr/idx + 0.5 + 10e-9;
	printf("%.0f\n",res);
}

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

int main(){
	string t; cin >> t; t += "-";
	vector< pair<char,int> > joi;
	int len = 1;
	for(int i = 1 ; i < t.size() ; i++){
		if(t[i] != t[i-1]){
			joi.push_back(make_pair(t[i-1],len));
			len = 1;
		}else{
			len++;
		}
	}
	int ans = 0;
	for(int i = 0 ; i <= (int)joi.size()-2 ; i++){
		if(joi[i].first == 'J' && joi[i+1].first == 'O' && joi[i+2].first == 'I'){
			if(!(joi[i+1].second > joi[i].second || joi[i+1].second > joi[i+2].second)){
				ans = max(ans,min(joi[i].second,min(joi[i+1].second,joi[i+2].second)));
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 9356
a,b,c,x,y = map(int, input().split())
ans = a*x + b*y
for i in range(1, max(x,y)+1):
    if (max((x-i),0)*a + max((y-i),0)*b + c*2*i) < ans:
        ans = (max((x-i),0)*a + max((y-i),0)*b + c*2*i)
print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define tll tuple<ll, ll, ll>
#define all(c) c.begin(),c.end()

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
 
const ll inf = 1000000001;
const ll INF = 1e18;
const ll MOD = 1000000007;

char albt[26] = {'a','b','c','d','e','f','g','h','i','j','k','l',
                 'm','n','o','p','q','r','s','t','u','v','w','x',
                 'y','z'};

//vector<ll> g[202020];
//fill(score, score+202020, 0);
//vector<ll> v;

int main(){
  ll n, m;
  cin >> n >> m;
  ll s[n];
  for (int i=0;i<n;i++) cin >> s[i];
  ll t[m];
  for (int i=0;i<m;i++) cin >> t[i];
  
  ll dp[n+1][m+1];
  ll sum[n+1][m+1];
  
  for (int i=0;i<=n;i++){
    dp[i][0] = 0;
    sum[i][0] = 0;
  }
  for (int i=0;i<=m;i++){
    dp[0][i] = 0;
    sum[0][i] = 0;
  }
  
  for (int i=1;i<=n;i++){
    for (int j=1;j<=m;j++){
      if (s[i-1] != t[j-1]) dp[i][j] = 0;
      else dp[i][j] = (sum[i-1][j-1] + 1)%MOD;
      
      sum[i][j] = (sum[i-1][j] + sum[i][j-1] - sum[i-1][j-1] + dp[i][j])%MOD;
      //cout << i << " " << j << " " << dp[i][j] << " " << sum[i][j] << endl;
    }
  }
  
  if (sum[n][m]<0) sum[n][m]+=MOD;
  cout << (sum[n][m]+1)%MOD << endl;
}

Measured memory_bytes: 62848
#include<bits/stdc++.h>
#define rep(i, n) for(i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007
 
int main(){
  double N, i, ans;
  cin >> N;
  
  ans = ceil(N/2);
 
  cout << ans << endl;
  return 0;
}

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

int main(){
	int n, cb, kembali, awal, diskon, total;
	cin >> n;
	awal = n*800;
	kembali = n/15;
	diskon = kembali*200;
	total = awal-diskon;
	cout << total << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static Input;

public class Prog
{
    private const int INF = 1000000007;
    private const long INFINITY = 9223372036854775807;
    public static void Main()
    {
        string S = NextString();
        bool[] done = Enumerable.Repeat(true, 26).ToArray();
        foreach (char c in S) { done[(int)c - 97] = false; }
        if (S.Length < 26)
        {
            for (int i = 0; i < 26; i++)
            {
                if (done[i])
                {
                    Console.WriteLine(S + ((char)(i + 97)).ToString());
                    return;
                }
            }
        }
        else if (S == "zyxwvutsrqponmlkjihgfedcba") Console.WriteLine(-1);
        else
        {
            string ans = "";
            done = Enumerable.Repeat(true, 26).ToArray();
            for (int i = 0; i < 26; i++)
            {
                done[S[i] - 97] = false;
                //i文字目変えてみる
                for (int j = 0; j < 26; j++)
                {
                    string _ans = S.Substring(0, i);
                    if (done[j])
                    {
                        _ans += ((char)(j + 97)).ToString();
                        if (S.CompareTo(_ans) == -1)
                        {
                            if (ans == "" || _ans.CompareTo(ans) == -1) ans = _ans;
                        }
                    }
                }
            }
            Console.WriteLine(ans);
        }
    }
}

public class Input
{
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}


Measured memory_bytes: 13396
def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

p = 10 ** 9 + 7
N = 10 ** 6  # N は必要分だけ用意する
fact = [1, 1]
factinv = [1, 1]
inv = [0, 1]
 
for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)

X, Y = map(int, input().split())

if (2*Y-X)%3 == 0:
    if (2*X-Y)%3 == 0:
        a = (2*Y-X)//3
        b = (2*X-Y)//3
    else:
        print(0)
        exit()
else:
    print(0)
    exit()

print(cmb(a+b, a, p))


Measured memory_bytes: 127880
#include<iostream>
using namespace std;
#define N 10000

int main(void){
	int x[N],num=0;
	bool flag=0;
	while(flag==0){
		cin>>x[num];
		if(x[num]==0)break;
		num++;
	}
	for(int i=0;i<num;i++){
		cout<<"Case "<<i+1<<": "<<x[i]<<endl;
	}
}


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

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)

using ll = long long;
using ld = long double;
ll INF = LLONG_MAX;

using vi = vector<int>;
using vll = vector<ll>;
using pii = pair<int, int>;

namespace output {
	void pr(int x) { cout << x; }
	void pr(long x) { cout << x; }
	void pr(ll x) { cout << x; }
	void pr(unsigned x) { cout << x; }
	void pr(unsigned long x) { cout << x; }
	void pr(unsigned long long x) { cout << x; }
	void pr(float x) { cout << x; }
	void pr(double x) { cout << x; }
	void pr(ld x) { cout << x; }
	void pr(char x) { cout << x; }
	void pr(const char* x) { cout << x; }
	void pr(const string& x) { cout << x; }
	void pr(bool x) { pr(x ? "true" : "false"); }
	template<class T> void pr(const complex<T>& x) { cout << x; }
	
	template<class T1, class T2> void pr(const pair<T1,T2>& x);
	template<class T> void pr(const T& x);
	
	template<class T, class... Ts> void pr(const T& t, const Ts&... ts) { 
		pr(t); pr(ts...); 
	}
	template<class T1, class T2> void pr(const pair<T1,T2>& x) { 
		pr("{",x.f,", ",x.s,"}"); 
	}
	template<class T> void pr(const T& x) { 
		pr("{"); // const iterator needed for vector<bool>
		bool fst = 1; for (const auto& a: x) pr(!fst?", ":"",a), fst = 0; 
		pr("}");
	}
	
	void print() { pr("\n"); } // print w/ spaces
	template<class T, class... Ts> void print(const T& t, const Ts&... ts) { 
		pr(t); if (sizeof...(ts)) pr(" "); print(ts...); 
	}
}

using namespace output;

int N = 26, D;
vi last (N, -1);
vi CS (N);
vector<vi> SAT;

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

	cin >> D;
	F0R(i, N) cin >> CS[i];
	SAT = vector<vi> (D, vi (N));
	F0R(i, D) F0R(j, N) cin >> SAT[i][j];
	
	vi ans (D);
	vector<set<int>> occ (N);
	F0R(i, N) {
		occ[i].insert(-1);
		occ[i].insert(D);
	}

	int sat = 0;
	F0R(i, D) {
		int choice; cin >> choice; --choice;
		
		// precomp
		ans[i] = choice;
		occ[choice].insert(i);

		// calc
		sat += SAT[i][choice];
		last[choice] = i;
		F0R(j, N) sat -= CS[j] * (i - last[j]);
	}

	int M; cin >> M;
	F0R(i, M) {
		int day, choice, before, after; cin >> day >> choice; --day; --choice;

		int cur = ans[day]; 
		sat -= SAT[day][cur];
		sat += SAT[day][choice];		
		
		// reduce sat
		before = *(--occ[cur].lower_bound(day));
		after = *occ[cur].upper_bound(day);
		sat -= CS[cur] * (day - before) * (after - day);

		// increase sat
		before = *(--occ[choice].upper_bound(day));
		after = *occ[choice].upper_bound(day);
		sat += CS[choice] * (day - before) * (after - day);

		// update variables
		occ[cur].erase(day);
		occ[choice].insert(day);
		ans[day] = choice;

		print(sat);
	}	
}

Measured memory_bytes: 3692
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N,K;
    cin>>N>>K;
    int total=0;
    for(int i=0;i<N;++i){
        int x;
        cin>>x;
        total+=min(x,abs(K-x))*2;
    }
    cout<<total<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
#include <map>
#include <stack>
using namespace std;
typedef long long int lli;
int main(void)
{
    int h1, h2, m1, m2, k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    int finh1, finm1;
    if (m2 - k < 0)
    {
        finh1 = h2 - 1;
        finm1 = m2 - k + 60;
    }
    else
    {
        finh1 = h2;
        finm1 = m2 - k;
    }
    cout << (finh1 - h1) * 60 + (finm1 - m1) << endl;
    return 0;
}

Measured memory_bytes: 3592
// C - Vacation
#include <bits/stdc++.h>
using namespace std;

int main(){
	int N; cin>>N;
	int A=0, B=0, C=0;
	while(N--){
		int a,b,c; cin>>a>>b>>c;
		a += max(B,C); b += max(C,A); c += max(A,B);
		A=a; B=b; C=c;
	}
	cout<< max({A,B,C});
}

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 int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    long double a, b;
    cin >> a >> b;
    long double ans = a * b;
    ans = floor(ans);
    ll out = (ll)ans;
    cout << out << endl;
    return 0;
}

Measured memory_bytes: 3744
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
static const int INF = 0x3f3f3f3f; static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
template<typename T, typename U> static void amin(T &x, U y) { if (y < x) x = y; }
template<typename T, typename U> static void amax(T &x, U y) { if (x < y) x = y; }

int main() {
	int X;
	while (~scanf("%d", &X)) {
		int i;
		for (i = 1; X > 0; ++ i)
			X -= i;
		printf("%d\n", i - 1);
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using VI = vector<int>;

const int N = 1e5 + 10;
ll a[N];
bool vis[N];
vector<ll> cur;
VI adj[N];

void dfs(int u) {
  if (vis[u]) return;
  vis[u] = true;
  cur.push_back(a[u]);
  for (int v: adj[u]) dfs(v);
}



int main() {
#ifdef LOCAL_EXEC
//	freopen("sample.in", "r", stdin);
//	freopen("sample.out", "w", stdout);
#else
  ios_base::sync_with_stdio(false); cin.tie(NULL);
#endif

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

  for (int i = 0; i < m; i++) {
    int u, v; cin >> u >> v;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }

  vector<ll> rem;
  ll ans = 0;
  int tot = (n - 1 - m) * 2;
  int comps = 0;
  for (int u = 0; u < n; u++) {
    if (!vis[u]) {
      dfs(u);
      sort(cur.rbegin(), cur.rend());
      ans += cur.back();
      cur.pop_back();
      for (ll x: cur) rem.push_back(x);
      cur.clear();
      tot--;
      comps++;
    }
  }
  if (comps == 1) {
    cout << 0 << endl;
  } else if (tot < 0 || tot > (int) rem.size()) {
    cout << "Impossible" << endl;
  } else {
    sort(rem.begin(), rem.end());
    rem.resize(tot);
    for (ll x: rem) ans += x;
    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 11976
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.IntSummaryStatistics;
import java.util.Iterator;
import java.util.PrimitiveIterator;
import java.util.Scanner;
import java.util.stream.IntStream;
import java.util.stream.Stream;

class Main{
	private void solve(){
		int[] v=new int[3];
		s.next().chars().map(i->i-'a').forEach(i->++v[i]);
		IntSummaryStatistics iss=Arrays.stream(v).summaryStatistics();
		System.out.println(iss.getMax()-iss.getMin()<2?"YES":"NO");
	}

	public static void main(String[] $){
		new Main().solve();
		System.out.flush();
	}


	static class System{
		private static final InputStream	in	=java.lang.System.in;
		private static final PrintWriter	out	=new PrintWriter(java.lang.System.out,false);
	}

	static Scanner s=new Scanner(System.in);


	static int gInt(){
		return s.nextInt();
	}

	static long gLong(){
		return s.nextLong();
	}

	static long gDouble(){
		return s.nextLong();
	}


	static Range rep(int i){
		return new Range(i);
	}

	static Range rep(int f,int t){
		return new Range(f,t);
	}

	static class Range implements Iterable<Integer>,PrimitiveIterator.OfInt{
		int from,to,c;
		Range(int from,int to){
			this.from=from;
			this.to=to;
			this.c=from;
		}
		Range(int n){
			this(0,n-1);
		}
		@Override
		public Iterator<Integer> iterator(){
			return this;
		}
		@Override
		public boolean hasNext(){
			return c<=to;
		}
		@Override
		public int nextInt(){
			return c++;
		}
	}


	static IntStream REPS(int v){
		return IntStream.range(0,v);
	}

	static IntStream REPS(int l,int r){
		return IntStream.rangeClosed(l,r);
	}


	static IntStream ints(int n){
		return REPS(n).map(i->gInt());
	}

	static Stream<String> strs(int n){
		return REPS(n).mapToObj(i->s.next());
	}

}

Measured memory_bytes: 27160
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
const int maxn=1e4+100;
typedef long long int LL;
LL s[2][maxn]={};
const LL mod=1e9+7;
int main()
{
    LL n,k;
    scanf("%lld%lld",&n,&k);
    memset(s,0,sizeof(s));
    s[1&1][1]=1;
    for(int i=2;i<=n;i++)
        for(int j=1;j<=i;j++) s[i&1][j]=(s[(i-1)&1][j-1]+s[(i-1)&1][j]*j)%mod;
    printf("%lld\n",s[n&1][k]);
    return 0;
}



Measured memory_bytes: 3388
#include<iostream>
#include<algorithm>
using lint=int64_t;
using namespace std;

int main()
{
	int N;
	int p[30]={};

	cin >> N;
	for(int i=0;i<N;i++)
		cin >> p[i];
	
	int ans=0;
	for(int i=1;i<=N-2;i++)
	{
		if((p[i-1]<p[i] && p[i]<p[i+1]) || (p[i-1]>p[i] && p[i]>p[i+1]))
			ans++;
	}

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



Measured memory_bytes: 256
#include <stdlib.h>
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
using ll=long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}
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 long long INF=1LL << 60;
long long a,b;
long long dp[100200][110];
long long w[110],v[110];


int main(){
    long long a,b;
    cin>>a>>b;
    if(a==1||b==1){
        cout<<1<<endl;
    }
    else if((a*b)%2==0){
            cout<<a*b/2<<endl;
        }
        else{
            cout<<a*b/2+1<<endl;
        }
}





Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define SELECTER(_1, _2, _3, SELECT, ...) SELECT
#define REP1(i, n) for(int (i)=0; (i)<(n); (i)++)
#define REP2(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define REP(...) SELECTER(__VA_ARGS__, REP2, REP1,) (__VA_ARGS__)
#define MOD 1'000'000'007

template <class T> ostream& operator<<(ostream& os, const vector<T>& v){ os << "{"; for(size_t i=0; i<v.size(); i++) os << v[i] << (i+1==v.size() ? "" : ", "); os << "}"; return os; }
template <class T, class U> ostream& operator<<(ostream& os, const pair<T, U>& p){ return os << "{" << p.first << ", " << p.second << "}"; }

long long solve(long long n){
    if(n%2==1) return 0;
    n /= 2;
    long long ans = 0;
    for(int i=0; i<30; i++){
        ans += n / 5;
        n /= 5;
    }
    return ans;
}

int main(){
    long long N;
    cin >> N;
    cout << solve(N) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n, x, l;
  	vector<pair<int,int>> v;
  	scanf("%d",&n);
  	for (int i = 0; i < n; i++) {
      	scanf("%d%d",&x,&l);
      	v.push_back({x+l,x-l});
    }
  	sort(v.begin(),v.end());
    int cnt = 1, prev = 0;
  	for (int i = 1; i < n; i++) {
    	if (v[i].second >= v[prev].first) {
			cnt++;
          	prev = i;
        }
    }
  	printf("%d\n",cnt);
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
#define all(r) r.begin(),r.end()
using namespace std;
typedef int64_t ll;
typedef vector<ll> vll;
struct Solution {
    void solve(std::istream& in, std::ostream& out) {
        ll n;
        in >> n;
        map<ll, ll> sa;
        vll va;
        for (int i = 0; i < n; i++) {
            ll tmp;
            in >> tmp;
            va.emplace_back(tmp);
            sa[tmp]++;
        }
        sort(all(va));
        va.erase(unique(all(va)), va.end());
        ll ans = 0;
        for (auto i : va) {
            if (i <= sa[i]) {
                ans += sa[i] - i;
            }
            else {
                ans += sa[i];
            }
        }
        out << ans << '\n';
    }
};
void solve(std::istream& in, std::ostream& out) {
    out << std::setprecision(12);
    Solution solution;
    solution.solve(in, out);
}
#include <fstream>
#include <iostream>
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    istream& in = cin;
    ostream& out = cout;
    solve(in, out);
    return 0;
}


Measured memory_bytes: 7028
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <regex>
#include <vector>

#define fix(n)          cout<<fixed<<setprecision(n)
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define all(a)          (a).begin(), (a).end()
#define sort(a)         sort(all(a))
#define uniq(a)         sort(a);(a).erase(unique(all(a), (a).end())
#define reverse(a)      reverse(all(a))
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d)
#define outl(d)         std::cout<<(d)<<"\n"
#define YES()           cout << "YES" << endl
#define NO()            cout << "NO" << endl
#define Yes()           cout << "Yes" << endl
#define No()            cout << "No" << endl
#define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }

using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;

const ll MOD = 1000000007; // 10^9 + 7
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

void solve() {
  int n; cin >> n;
  int sum = 0;
  rep(i, n) {
    int a; cin >> a;
    sum ^= a;
  }
  if (sum == 0) Yes();
  else No();
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12);

  solve();
}


Measured memory_bytes: 384
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();

		String s = "No" ;

		if ( a==b || b==c || c==a )  s = "Yes" ;
		if ( a==b && b==c ) s = "No" ;
		// 出力
		System.out.println(s);
	}
}

Measured memory_bytes: 23764
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.regex.Pattern;
import java.util.stream.Stream;;

public class Main {

  public static void main(String[] args) {
    new Main().run();
  }

  public void run() {
    
    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      String[] lines = br.readLine().split(" ");
      int  n = Integer.parseInt(lines[0]);
      long z = Long.parseLong(lines[1]);

      final Pattern delim = Pattern.compile(" ");
      long d = delim
        .splitAsStream(br.readLine())
        .mapToLong(Long::parseLong)
        .map(l -> Math.abs(l-z))
        .reduce(Main::gcd)
        .getAsLong();
      
      System.out.println(d);
    }
    catch(IOException e) {
      System.err.println(e);
    }
  }
  
  public static long gcd(long x, long y) {
    if( x<y ) {
      long tmp = x; x = y; y = tmp;
    }
    if( (x%y) == 0 ) return y;
    else return gcd(y,x%y);
  }
}

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

int table[101][101];

int main(){

int r; cin >> r;
int c; cin >> c;

for(int i=0; i<r; i++){
	for(int j=0; j<c; j++){
		cin >> table[i][j];
		table[i][c] += table[i][j];
		table[r][j] += table[i][j];
		table[r][c] += table[i][j];
	}
}
for(int i=0; i<=r; i++){
	for(int j=0; j<=c; j++){
		cout << table[i][j] << ((j!=c)? " " : "");
	}
	cout << endl;
}
return 0;
}

Measured memory_bytes: 3148
#include <stdio.h>
int main(){
    int i;
    int a,b,c,d=0;
    scanf("%d %d %d",&a,&b,&c);
    for(i=1;i<=b;i++){
        if(a*i%b==c){
            printf("YES\n");
            d=1;
            break;
        }

    }
    if(d==0){
        printf("NO\n");
    }
return 0;
}


Measured memory_bytes: 128
h,w = map(int,input().split())
l = [list(input()) for i in range(h)]

x = 0
y = 0
while True:
    if l[x][y] == "#":
        l[x][y] = "."
        if y < w-1 and l[x][y+1] == "#":
            y += 1
        elif x < h-1 and l[x+1][y] == "#":
            x += 1
        else:
            break
    else:
        break
for i in l:
    if "#" in i:
        print("Impossible")
        exit()
print("Possible")

Measured memory_bytes: 9204
import sys
def N(n):
    return (n+1)*(n+2)*(n+3)/6
for n in sys.stdin:
        n = int(n)
        if n > 2000:
            n = 4000 - n
        if n < 1001:
            print N(n)
        else:
            m = n - 1000
            print N(n) - (N(2*m) - m - 1)/2

Measured memory_bytes: 4208