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

using namespace std;

#define pb push_back
#define fi first
#define se second
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define REP(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define RREP(i, n) FOR(i, n, 0)
#define MFOR(i, m) for(auto i=(m).begin();i!=(m).end();i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())

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

const double eps = 1e-10;
const int MOD = 1000000007;

template<typename T>
void printv(vector<T> const& s) {
  REP(i, SZ(s)) {
    cout << s[i] << " ";
  }
  cout << endl;
}

vvi f;
vvi p;
const int INF = -2000000000;

int solve(int n, vi t) {
  if(t.size() == 10) {
    int ma = 0;
    REP(i, 10) {
      ma = max(ma, t[i]);
    }
    if(ma == 0) {
      return INF;
    } else {
      int ans = 0;
      REP(i, n) {
        int cnt = 0;
        REP(j, 10) {
          if(t[j] == f[i][j] && t[j] == 1) cnt++;
        }
        ans += p[i][cnt];
      }
      return ans;
    }
  } else {
    t.pb(0);
    int tmp1 = solve(n, t);
    t[SZ(t)-1] = 1;
    int tmp2 = solve(n, t);
    return max(tmp1, tmp2);
  }
}

int main () {
  cin.tie(0);
  cout << setprecision(10);

  int n; cin >> n;
  f.resize(n);
  REP(i, n) {
    f[i].resize(10);
    REP(j, 10) {
      cin >> f[i][j];
    }
  }

  p.resize(n);
  REP(i, n) {
    p[i].resize(11);
    REP(j, 11) {
      cin >> p[i][j];
    }
  }

  vi t;
  cout << solve(n, t) << endl;;
}


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

int main(){
	int k;
	cin >> k;
	string s;
	cin >> s;
	if(s.size() <= k){
		cout << s << "\n";
	} else {
		cout << s.substr(0, k) + "..." << "\n";
	}
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define FOR(I,X,Y) for(long long (I)=(X);(I)<(Y);(I)++)
#define REP(I,X,Y) for(long long (I)=(Y)-1;(I)>=(X);(I)--)
#define ALL(X) (X).begin(),(X).end()
#define pb push_back
#define COUNT(V,X) upper_bound((V).begin(),(V).end(),X)-lower_bound((V).begin(),(V).end(),X)
#define debug(x) cerr<<#x<<':'<<x<<endl;
#define DEBUG(v) cerr<<#v<<':';for(auto x:v)cerr<<x<<' ';cerr<<endl;
#define INF 1000000007
#define LINF 1000000000000000007
#define EPS 1e-9
typedef long long ll;

struct WeightedUnionFind{
  vector<long long> data;
  vector<long long> dif;
  void boot(long long n){
    for(long long i = 0;i < n;i++)data.push_back(-1);
    for(long long i = 0;i < n;i++)dif.push_back(0);
    return;
  }
  long long root(long long x){
    if(data[x] < 0)return x;
    long long r = root(data[x]);
    dif[x] += dif[data[x]];
    return data[x] = root(data[x]);
  }
  long long weight(long long x){
    root(x);
    return dif[x];
  }
  bool same(long long x,long long y){
    return root(x) == root(y);
  }
  void unite(long long x,long long y,long long w){
    if(!same(x,y)){
      w += weight(x);
      w -= weight(y);
      x = root(x);
      y = root(y);
      if(data[x] < data[y]){
        data[x] += data[y];
        data[y] = x;
        dif[y] = w;
      }
      else{
        data[y] += data[x];
        data[x] = y;
        dif[x] = -w;
      }
    }
    return;
  }
  long long getsize(long long x){
    return -data[root(x)];
  }
  long long diff(long long x,long long y){
    return dif[y] - dif[x];
  }
};

signed main(){
  int n,q;
  cin >> n >> q;
  WeightedUnionFind UF;
  UF.boot(n);
  int query,x,y,z;
  FOR(i,0,q){
    cin >> query;
    if(query == 0){
      cin >> x >> y >> z;
      UF.unite(x,y,z);
    }
    else{
      cin >> x >> y;
      if(!UF.same(x,y))cout << "?" << endl;
      else cout << UF.diff(x,y) << endl;
    }
  }
}


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

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

	cin >> a >> b >> c;

	if(a > b) {
		t = a;
		a = b;
		b = t;
	}

	if(b > c){
		t = b;
		b = c;
		c = t;
	}

	if(a > b){
		t = a;
		a = b;
		b = t;
	}

	cout << a << " " << b << " " << c << endl;

	return 0;
}


Measured memory_bytes: 3100
# import sys
# input = sys.stdin.readline
import collections
import itertools

def main():
    n, k = input_list()
    a = input_list()
    if (n - 1) % (k - 1) == 0:
        print((n-1) // (k-1))
    else:
        v = (n-1) // (k-1)
        print(v + 1)


def input_list():
    return list(map(int, input().split()))


def input_list_str():
    return list(map(str, input().split()))


if __name__ == "__main__":
    main()


Measured memory_bytes: 84068
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int a[]=new int [3];
		int b=0;
		int k=0;
		for(int i=0;i<3;i++) {
			a[i]=sc.nextInt();
			if(a[i]>b) {
				b=a[i];
				k=i;
			}
		}
		int K=sc.nextInt();
		for(int i=0;i<K;i++) {
			a[k]=a[k]*2;
		}
		k=0;
		for(int i=0;i<3;i++) {
			k=a[i]+k;
		}
		System.out.println(k);
	}
}

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

using namespace std;
using ll = long long;
using ld = long double;

const int MOD = 998244353;

int main () {
	int n, k;
	cin >> n >> k;
	vector<pair<int, int>> ar(k);
	for (int i = 0; i < k; i++) {
		cin >> ar[i].first >> ar[i].second;
	}

	vector<ll> dp (n + 1);
	dp[1] = 1;
	
	for (int i = 2; i <= n; i++) {
		for (int j = 0; j < k; j++) {
			if (i <= ar[j].first) {
				continue;
			} else if (i <= ar[j].second) {
				dp[i] += dp[i - ar[j].first];
			} else {
				dp[i] += dp[i - ar[j].first] - dp[i - ar[j].second - 1];
			}
			dp[i] = (dp[i] + MOD) % MOD;
		}
		if (i != n) dp[i] += dp[i - 1];
	}
	cout << dp[n] << '\n';
}


Measured memory_bytes: 4828
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    HashMap<Integer, Long> map = new HashMap<Integer, Long>();
    long ans = 0;
    int[] a = new int[n];
    for(int i = 0; i < n; i++) {
      a[i] = sc.nextInt();
      if(map.containsKey(a[i])) {
        ans += map.get(a[i]);
        map.put(a[i], map.get(a[i]) + 1);
      } else {
        map.put(a[i], (long)1);
      }
    }
    for(int i = 0; i < n; i++) {
      System.out.println(ans - map.get(a[i]) + 1);
    }
  }
}

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

app = list(range(-1+a[1]+1,a[0]+a[1]-1+1))
apabs = list(range(-1+a[1]+1,a[0]+a[1]-1+1))

for i in range(len(app)):
    if app[i]<0:
        apabs[i]=app[i]*-1
    else:
        apabs[i]=app[i]
if min(apabs) == abs(max(app)):
    k=max(app)
    out=sum(app)-k
else:
    k=min(apabs)
    out=sum(app)-k        
    
print(out)


Measured memory_bytes: 3064
#include<stdio.h>
int main(void)
{

  for( ; ; )
    {
      int m,f,r;
      scanf("%d%d%d",&m,&f,&r);
      if(m==-1 && f==-1 && r==-1){break;}
      else  if(m==-1 || f==-1){printf("F\n");}
      else if(m+f>=80){printf("A\n");}
      else if(m+f>=65){printf("B\n");}
      else if(m+f>=50){printf("C\n");}
      else if(m+f>=30)
	{
	  if(r>=50){printf("C\n");}
	  else{printf("D\n");}
	}
      else {printf("F\n");}
    }
  return 0;
}

Measured memory_bytes: 584
fn read<T: std::str::FromStr>(
    stdin_lock: &mut std::io::StdinLock,
    buf: &mut Vec<u8>,
    delimiter: u8,
) -> T {
    buf.clear();
    let l = std::io::BufRead::read_until(stdin_lock, delimiter, buf).unwrap();
    buf.truncate(l - 1); // remove delimiter
    let s = unsafe { std::str::from_utf8_unchecked(&buf) };
    s.parse().unwrap_or_else(|_| panic!("read"))
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin_lock = stdin.lock();
    let mut buf: Vec<u8> = Vec::new();
    let n: usize = read(&mut stdin_lock, &mut buf, b' ');
    let k: i32 = read(&mut stdin_lock, &mut buf, b' ');
    let q: usize = read(&mut stdin_lock, &mut buf, b'\n');
    let mut av = vec![0usize; q];
    for i in 0..q {
        av[i] = read(&mut stdin_lock, &mut buf, b'\n');
    }

    let mut cv = vec![0i32; n];
    for i in 0..q {
        cv[av[i] - 1] += 1;
    }

    for i in 0..n {
        println!(
            "{}",
            if (k + cv[i]) as usize > q {
                "Yes"
            } else {
                "No"
            }
        )
    }
}


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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

using namespace std;
using ll = long long;

const ll MOD = 1000000007LL; // = 10^9 + 7
const double PI = 3.14159265358979;

void solve()
{
  int n, i;
  cin >> n >> i;
  cout << n - i + 1;
}

int main()
{
  fastio;
  solve();

  return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF (1LL<<50)
#define MOD 1000000007

int main(){
    int count[100010]={};
    int N;
    cin >> N;
    vector<int> A(N);
    vector<ll> dp(N);
    cin >> A[0];
    if(A[0]!=0){
        cout << 0 << endl;
        return 0;
    }
    dp[0] = 3;
    count[0] = 1;

    for(int i=1;i<N;i++){
        cin >> A[i];
        count[A[i]]++;
        if(A[i]==0){
            dp[i] = dp[i-1] * (4-count[0]);
            dp[i] %= MOD;
            continue;
        }
        dp[i] = dp[i-1] * (count[A[i]-1] - count[A[i]] + 1);
        dp[i] %= MOD;
    }
    if(dp[N-1]<0){
        dp[N-1] = 0;
    }
    cout << dp[N-1] << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <stdint.h>
#include <inttypes.h>
#include <stdio.h>

uint64_t xorsum(uint64_t n)
{
  return n % 4 == 0 ? n : n ^ xorsum(n - 1);
}

int main(void)
{
  uint64_t a, b;
  scanf("%" SCNu64 "%" SCNu64, &a, &b);
  printf("%" PRIu64 "\n", a ^ xorsum(a) ^ xorsum(b));
}


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

int main(){
  string S;
  cin >> S;
  int count = 700;
  if(S[0]=='o'){
    count+= 100;}
  if(S[1]=='o'){
    count +=100;}
   if(S[2]=='o'){
     count+=100;}
  
  cout << count<<endl;
}
    

Measured memory_bytes: 3516
#include<iostream>
#include<vector>
#include<queue>
using namespace std;
int dx[][6] = {{1, 0, -1, -1, -1,  0},
               {1, 1, 0, -1,  0,  1}
};
int dy[][6] = {{0, 1,  1,  0, -1, -1},
              {0, 1, 1,  0, -1, -1}
};
  
typedef struct store{
  int x, y;
}store;

bool range(int x, int y, int mx, int my){
  if((0 <= x and x < mx) and (0 <= y and y < my))return true;
  else return false;
}
  

void computeDist(vector<vector<int> > &field, store st){
  field[st.y][st.x] = 0;
  queue<pair<store, int> > que;
  que.push(pair<store, int>(st, 0));
  while(not que.empty()){
    store s  = que.front().first;
    int dist = que.front().second;
    que.pop();
    for (int i = 0; i < 6; i++) {
      int d = s.y&1;
      if(not range(s.x + dx[d][i], s.y + dy[d][i], field[0].size(), field.size()))continue;
      if(field[dy[d][i] + s.y][dx[d][i] + s.x] > dist + 1){
        field[dy[d][i] + s.y][dx[d][i] + s.x] = dist + 1;
        que.push(pair<store, int>((store){s.x + dx[d][i], s.y + dy[d][i]}, dist + 1));
      }
    }
  }
}
  

int main(){
  int m, n;
  while(std::cin >> m >> n, n){
    int s, t, x, y;
    std::cin >> s;
    vector<store> vs(s, (store){0, 0});
    vector<vector<vector<int> > > field(s, vector<vector<int> >(n, vector<int>(m, 1e9)));
    for (int i = 0; i < s; i++) {
      std::cin >> x >> y;
      vs[i] = (store){--x, --y};
    }
    std::cin >> t;
    vector<store> vp(t);
    for (int i = 0; i < t; i++) {
      std::cin >> x >> y;
      vp[i] = (store){--x, --y};
    }
    for (int i = 0; i < s; i++) computeDist(field[i], vs[i]);
    // for (int i = 0; i < n; i++) {
    //   for (int j = 0; j < m; j++) {
    //     std::cout << field[0][i][j] << " ";
    //   }
    //   std::cout << std::endl;
    // }
    int ans = 0;
    for (int loop = 0; loop < t; loop++) {
      vector<vector<int> > covered(n, vector<int>(m, 1e9));
      computeDist(covered, vp[loop]);
      int val = 0;
      for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
          int mini = covered[i][j], type = -10;
          for (int k = 0; k < s; k++) {
            if(mini >= field[k][i][j]) break;
            if(k == s - 1)val++;
          }
        }
      }
      ans = max(ans, val);
    }
    std::cout << ans << std::endl;
  }
  return 0;
}



Measured memory_bytes: 3044
#include <iostream>
#include <cassert>
#include <cmath>
using namespace std;

long long LINF = (long long) 1e18;

long long mul(long long a, long long b) {
    if (b == 0 || a <= LINF / b) return a * b;
    return LINF;
}

long long power(long long a, long long n) {
    long long res = 1;
    for (int i = 0; i < n; ++i) {
        res = mul(res, a);
    }
    return res;
}

int main() {
    long long n; cin >> n;
    long long a; cin >> a;
    long long res = n;
    for (int foo = 2; ; ++foo) {
        long long x = pow(n, 1.0 / foo);
        //cout << foo << ' ' << x << ' ' << pow(n, 1.0 / foo) << endl;
        while (power(x + 1, foo) <= n) ++x;
        while (power(x, foo) > n) --x;
        if (x == 1) break;
        //cout << foo << ' ' << x << endl;
        assert(power(x, foo) <= n);
        for (int bar = 0; bar <= foo; ++bar) {
            if (mul(power(x, bar), power(x + 1, foo - bar)) >= n) {
                //cout << x << ' ' << bar << ' ' << foo - bar << endl;
                res = min(res, mul(x, bar) + mul(x + 1, foo - bar) + mul(foo - 1, a));
            }
        }
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long int n,cnt=0;
  char a;
  string s;
  cin>>s>>n;
  for(int i=0;i<s.size();i++){
    if(s[i]!='1'){
      a=s[i];
      break;
    }
    else cnt++;
  }
  if(n<=cnt) cout<<1<<endl;
  else cout<<a<<endl;
  return 0;
}


Measured memory_bytes: 256
//#pragma GCC optimize("-O3")
/*
				C++
				encoding: UTF-8
				Last Modified: 03/May/20 05:30:53 PM
*/

#include <bits/stdc++.h>
#ifdef H4wk3ye
#	include <prettypr.hpp>
#endif

using namespace std;

// clang-format off

#define		int                    long long
#define		ve                     vector
#define		pb                     push_back
#define		endl                   "\n"
#define		ff                     first
#define		ss                     second
#define		pii                    pair<int, int>
#define		len(v)                 (int)v.size()
#define		all(v)                 v.begin(), v.end()
#define		reset(a, b)            memset(a, b, sizeof(a));
#define		fr(i, s, n)            for (int i = s ; i < n ; ++i)
#define		dfr(i, s, n)           for (int i = s ; i > n ; --i)

template < typename T > void pr (const T& t) {
    cout << t << "\n";
}

template < typename T, typename U, typename... ARGS >
void pr (const T& t, const U& u, const ARGS&... args) {
    cout << t << " ";
    pr (u, args...);
}

// clang-format on


signed main () {
	ios_base::sync_with_stdio (false), cin.tie (nullptr);
	string s;
	cin >> s;
	pr (s == "ABC" ? "ARC" : "ABC");
	return 0;
}

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

int main() {
  int n, l, i, keep = 0;
  cin >> n >> l;
  
  for(i = 0; i < n; i++){
    keep += l + i;
  }
  
  if(l >= 0) cout << keep - l << endl;
  else if(l + n - 1 >= 0) cout << keep << endl;
  else cout << keep - (l + n - 1) << endl;
}


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func main() {
	sc.Split(bufio.ScanWords)

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

	min := p[0]
	count := 0
	for _, v := range p {
		if v <= min {
			min = v
			count++
		}
	}
	fmt.Println(count)
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long int;
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 ll INF = 1e11;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
ll mon(ll x){
    if (x == 1) return 1;
    else return 2*mon(x/2)+1;
}
int main(){
    ll h;
    cin >> h;
    PRINT(mon(h));
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
//const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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 (a>b) { a=b; return 1; } return 0; }

class Point {
public:
  ld x, y;

  Point() {}
  Point(ld x, ld y): x(x), y(y) {}

  Point operator + (const Point &p) {
    return Point(x + p.x, y + p.y);
  }
  Point operator - (const Point &p) {
    return Point(x - p.x, y - p.y);
  }
  Point operator * (const ld k) {
    return Point(x * k, y * k);
  }
  Point operator / (const ld k) {
    return Point(x / k, y / k);
  }
  Point operator += (const Point &p) {
    x += p.x;
    y += p.y;
    return *this;
  }
  Point operator -= (const Point &p) {
    x -= p.x;
    y -= p.y;
    return *this;
  }
  Point operator *= (const ld k) {
    x *= k;
    y *= k;
    return *this;
  }
  Point operator /= (const ld k) {
    x /= k;
    y /= k;
    return *this;
  }
  bool operator < (const Point &p) const {
    return x != p.x ? x < p.x : y < p.y;
  }
  bool operator == (const Point &p) const {
    return equals(x, p.x) && equals(y, p.y);
  }
  friend ostream& operator << (ostream &os, const Point &p) {
    os << p.x << ' ' << p.y;
    return os;
  }
  friend istream& operator >> (istream &is, Point &p) {
    ld x, y;
    is >> x >> y;
    p = Point(x, y);
    return is;
  }

  ld abs() {return sqrt(norm());}
  ld norm() {return x * x + y * y;}
};

ld dot(Point a, Point b) {
  return a.x * b.x + a.y * b.y;
}

ld cross(Point a, Point b) {
  return a.x * b.y - a.y * b.x;
}

class Segment {
public:
  Point p1, p2;

  Segment() {}
  Segment(Point p1, Point p2): p1(p1), p2(p2) {}
};

//線分sに対する点pの射影
Point project(Segment s, Point p) {
  Point base = s.p2 - s.p1;
  ld r = dot(p - s.p1, base) / base.norm();
  return s.p1 + base * r;
}

//線分sを対称軸とした点pの線対象の点
Point reflect(Segment s, Point p) {
  return p + (project(s, p) - p) * 2;
}

class Circle {
public:
  Point p;
  ld r;

  Circle() {}
  Circle(Point p, ld r): p(p), r(r) {}
};

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(25);

  Segment s;
  cin >> s.p1 >> s.p2;
  int q;
  cin >> q;
  while (q--) {
    Point p;
    cin >> p;
    cout << reflect(s, p) << '\n';
  }

  

  
  return 0;
}


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

const int MOD = 1000000007;
const int INF = 1000000000;

//long long
using ll = long long;

//出力系
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()

//for
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

//最大公約数 
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

// 最小公倍数
unsigned lcm(unsigned a, unsigned b){
    return a / gcd(a, b) * b; 
}

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(){
  ll n;
  cin >> n;
  vector<ll>t(n);
  REP(i, n) cin >> t[i];
  vector<ll>a(n);
  REP(i, n) cin >> a[i];

  // vector<ll>check(n, -1);
  bool flag = true;

  vector<ll>nt(n);
  ll t_now = -1;
  REP(i, n){
    if(t_now < t[i]) nt[i] = 1, t_now = t[i];
    else nt[i] = t_now;
    // cout << t_now << endl;
  }
  vector<ll>na(n);
  ll a_now = -1;
  for(ll i = n - 1; i >= 0; i--){
    if(a_now < a[i]) na[i] = 1, a_now = a[i];
    else na[i] = a_now;
    // cout << a_now << endl;
  }

  REP(i, n){
    if(nt[i] == 1 && na[i] == 1) if(t[i] != a[i]) flag = false;
    if(nt[i] == 1) if(t[i] > a[i]) flag = false;
    if(na[i] == 1) if(a[i] > t[i]) flag = false;
  }
  //  for(auto x : nt) cout << x << "\n";

  ll ans = 1;
  if(flag){
    REP(i, n){
      ans *= min(na[i], nt[i]);
      ans %= MOD;
    }
  }

  flag ? cout << ans << "\n" : cout << 0 << "\n";
  return 0;

}


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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define copy(from, to) copy(from.begin(), from.end(), back_inserter(to));
#define sort(a) sort(a.begin(), a.end())
#define p(s) cout << (s) << endl;

typedef long long ll;
using namespace std;

template<class T>
void load(vector<T> &v, int n) {
  for (int i = 0; i < n; ++i) {
    T t;
    cin >> t;
    v.push_back(t);
  }
}


int main() {
  string s;
  cin >> s;

  if ((s[0] == s[1] && s[2] == s[3] && s[0] != s[2])
  || (s[0] == s[2] && s[1] == s[3] && s[0] != s[1])
  || (s[0] == s[3] && s[1] == s[2] && s[0] != s[1])) {
    p("Yes")
  } else {
    p("No")
  }
}

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

using namespace std;

typedef pair<int, int> P;

int A[100100];
int N;

void input(){
	scanf("%d", &N);
	for(int i = 0; i < N; ++i) scanf("%d", A + i);
}

map<int, int> e, o;

vector<P> evec, ovec;

int solve(){
	for(int i = 0; i < N; ++i){
		if(i % 2 == 0) e[A[i]]++;
		else o[A[i]]++;
	}
	map<int, int>::iterator it = e.begin();
	for(; it != e.end(); ++it){
		evec.push_back(P(it->second, it->first));
	}
	evec.push_back(P(0, -1));
	sort(evec.begin(), evec.end());
	reverse(evec.begin(), evec.end());
	it = o.begin();
	for(; it != o.end(); ++it){
		ovec.push_back(P(it->second, it->first));
	}
	ovec.push_back(P(0, -2));
	sort(ovec.begin(), ovec.end());
	reverse(ovec.begin(), ovec.end());
	if(evec[0].second != ovec[0].second){
		return N - evec[0].first - ovec[0].first;
	}else{
		int ma = max(evec[0].first + ovec[1].first, evec[1].first + ovec[0].first);
		return N - ma;
	}
}

int main(){
	input();
	int ans = solve();
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 6520
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
const int mod = 1e9 + 7;
const int INF = 1e9;
const double pi = acos(-1.0);
typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vi;
int main(){
    int x, n;
    cin >> x >> n;
    bool tmp = 1;
    vector<bool> l(100,1), r(100,1);
    rep(i,n){
        int p; cin >> p;
        if(p == x)tmp = 0;
        if(abs(p - x) <= 50){
            if(p < x)l[x-p]=0;
            else r[p-x]=0;
        }
    }
    

    if(tmp){
        //cout << "000" << endl;
        cout << x << endl;
        return 0;
    }
    bool ok = 0;
    int i=1;
    while(!ok){
        if(l[i]){
            //cout << "111" << endl;
            cout << x-i << endl;
            ok = 1;
        }
        else if(r[i]){
            //cout << "222" << endl;
            cout << x+i << endl;
            ok = 1;
        }
        i++;
    }

    return 0;
}  

Measured memory_bytes: 3616
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <fstream> //ofstream
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
int n,m;
void solve(){
        if(n==m) {
                cout<<"Yes"<<endl;
        }else{
                cout<<"No"<<endl;
        }
}

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

        solve();
        return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(c, i, n) for (int i = c; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    ll N;
    cin >> N;
    vector<ll> A(N);
    priority_queue<ll> pq;
    rep(0, i, N)
    {
        cin >> A.at(i);
        pq.push(A.at(i));
    }
    rep(0, i, N)
    {
        if (pq.top() != A.at(i))
        {
            cout << pq.top() << endl;
        }
        else
        {
            ll a = pq.top();
            pq.pop();
            cout << pq.top() << endl;
            pq.push(a);
        }
    }
}

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

int main(){
  int N,j=0;
  cin>>N;
  for(int i=0;i<=N;i++){
    int l=0;
    for(int k=1;k<=i;k++)
      if(i%k==0)
        l++;
    if(l==8 && i%2==1){
      j++;
    }
  }
  cout<<j<<endl;
}

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

int head = 1, tail = 0;
int n;

int enqueue(vector<pair<string, int>>& P, pair<string, int> p) {
    P[tail] = p;
    tail = (tail + 1) % (n + 1);
    return 0;
}

pair<string, int> dequeue(vector<pair<string, int>>& P) {
    pair<string, int> ret = P[head];
    head = (head + 1) % (n + 1);
    return ret;
}

int main() {
    int q, time = 0;
    cin >> n >> q;
    vector<pair<string, int>> P(n + 1);
    rep(i, n) cin >> P[i + 1].first >> P[i + 1].second;
    while (true) {
        pair<string, int> p = dequeue(P);
        time += min(q, p.second);
        p.second = max(0, p.second - q);
        if (p.second == 0) {
            cout << p.first << " " << time << endl;
        } else enqueue(P, p);
        if (head == tail) break;
    }
    return 0;
}


Measured memory_bytes: 5960
#include<iostream>
#include<iomanip>

#include<vector>
#include<queue>
#include<set>
#include<map>
#include<string>

#include<algorithm>
#include<cmath>

using namespace std;
typedef long long ll;
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;}
const long long INF = 1LL << 60;
typedef pair<int, int> P;

int main() {
    int n;
    cin >> n;
    vector<int> p(n);
    for (int i = 0; i < n; i++) cin >> p[i];
    
    for (int i = 0; i < n; i++) {
        for (int j = 1; j < n; j++) {
            swap(p[i],p[j]);
            int count = 0;
            for (int k = 0; k < n - 1; k++) {
                if (p[k] < p[k+1]) count++;
            }
            if (count == n - 1) {
                cout << "YES\n";
                return 0;
            }
            swap(p[i],p[j]);
        }
    }
    cout << "NO\n";
}

/* 
int main() {
    int a, b;
    cin >> a >> b;
    int tmp = abs(a - b);
    if (tmp % 2 == 1) {
        cout << "IMPOSSIBLE\n";
    } else {
        cout << (a+b)/2 << "\n";
    }
}*/

Measured memory_bytes: 256
#!python3

from time import perf_counter
limit = 1.92
tick = perf_counter()

import sys
iim = lambda: map(int, sys.stdin.readline().rstrip().split())
from random import randrange
from bisect import bisect


def resolve():
    G = 26
    it = map(int, sys.stdin.read().split())
    D = next(it)
    C = [next(it) for i in range(G)]
    S = [[next(it) for i in range(G)] for i in range(D)]
    L = [[-1] for i in range(G)]
    T = [0] * D

    def update(di, qi):
        score = 0
        t0 = T[di]
        score += S[di][qi]-S[di][t0]

        a1 = li = L[t0][:]
        ii = li.index(di)
        la = D if len(li)-1 == ii else li[ii+1]
        score -= C[t0] * (di-li[ii-1])*(la-di)
        li.pop(ii)

        a2 = li = L[qi][:]
        ii = bisect(li, di)
        li.insert(ii, di)
        la = D if len(li)-1 == ii else li[ii+1]
        score += C[qi] * (di-li[ii-1])*(la-di)

        return score, (a1, a2)

    U = 7
    def calc(i, j):
        score = S[i][j]
        for k in range(G):
            u = k - L[k][-1]
            score -= C[k] * (u + u + U) * U // 2
        score += C[k] * U * (i-L[j][-1])
        return score

    def dswap(di, dj):
        qi, qj = T[di], T[dj]
        swap0 = (L[qi], L[qj])

        score, swap1 = update(di, qj)
        T[di] = qj
        L[qi], L[qj] = swap1
        diff, swap2 = update(dj, qi)

        score += diff

        if score > 0:
            T[dj] = qi
            L[qj], L[qi] = swap2
        else:
            score = 0
            T[di], T[dj] = qi, qj
            L[qi], L[qj] = swap0
        return score

    def fullscore():
        score = 0
        last = [-1] * 26
        for i, ti in enumerate(T):
            score += S[i][ti]
            last[ti] = i
            for ci, la in zip(C, last):
                score -= ci * (i-la)
        return score

    for di in range(D):
        i, score = 0, calc(di, 0)
        for qi in range(1, G):
            x = calc(di, qi)
            if x > score:
                i, score = qi, x
        T[di] = i
        L[i].append(di)

    t = 0
    AB = 1
    score = fullscore()
    while t < limit:
        ab = randrange(0, AB)
        if ab > 50:
            di, qi = randrange(0, D), randrange(0, G)
            diff, swap = update(di, qi)
            if diff > 0:
                score += diff
                q0, T[di] = T[di], qi
                L[q0], L[qi] = swap
            else:
                if AB > 2:
                    AB -= 1
        else:
            di = randrange(0, (D-1)//2)
            dj = randrange(di+1, D)
            diff = dswap(di, dj)
            if diff > 0:
                score += diff
                AB = 100
        t = perf_counter() - tick


    print(*(i+1 for i in T), sep="\n")


if __name__ == "__main__":
    resolve()


Measured memory_bytes: 114396
#include<iostream>
#include<queue>
using namespace std;
int n, a[300], m; bool u1[300], u2[300];
int main() {
	while (true) {
		cin >> m; if (m == 0)break; cin >> n;
		for (int i = 0; i < 300; i++)a[i] = 0;
		for (int i = 1; i <= n; i++)cin >> a[i];
		for (int i = 0; i < 300; i++)u1[i] = false; u1[0] = true;
		for (int i = 0; i <= n; i++) {
			for (int j = 0; j <= n; j++) {
				if (u1[j] == false)continue;
				for (int k = 1; k <= m; k++) {
					int G = j + k; if (G > n)G = n + 1;
					G += a[G]; if (G < 0)G = 0; if (G > n)G = n + 1; u1[G] = true;
				}
			}
		}
		bool flag = false;
		for (int i = 0; i <= n; i++) {
			if (u1[i] == false)continue;
			for (int j = 0; j < 300; j++)u2[j] = false; u2[i] = true;
			queue<int>Q; Q.push(i);
			while (!Q.empty()) {
				int a1 = Q.front(); Q.pop();
				for (int j = 1; j <= m; j++) {
					int G = a1 + j; if (G > n)G = n + 1;
					G += a[G]; if (G < 0)G = 0; if (G > n)G = n + 1;
					if (u2[G] == false) { u2[G] = true; Q.push(G); }
				}
			}
			if (u2[n + 1] == false) { cout << "NG" << endl; flag = true; break; }
		}
		if (flag == false)cout << "OK" << endl;
	}
	return 0;
}

Measured memory_bytes: 3052
#include <stdio.h>
int main(void)
{ 
    int r, c, i, j;
    int table[101][101] = { };
    scanf("%d %d", &r, &c);
    for (j = 0; j < r; j++){
        for (i = 0; i < c; i++){
            scanf("%d", &table[j][i]);
            table[j][c] += table[j][i];
            table[r][i] += table[j][i];
            } 
        
    }
    for (i = 0; i < c; i++){
        table[r][c] += table[r][i];
        }
        for (j = 0; j <= r; j++){
            for (i = 0; i <= c; i++){
                printf("%d", table[j][i]);
                if (i < c){
                    printf(" ");
                }
                else{
                    printf("\n");
                }
            }
        }
    return 0;
} 


Measured memory_bytes: 2060
n = int(input())
A = list(map(int, input().split()))

answer = 1e15
for s in range(2): # start from + or -
  prev_cumsum=0
  num_man = 0
  for i, a in enumerate(A):
    if (prev_cumsum + a)*(-1)**(i+s) > 0:
      prev_cumsum += a
      #print(prev_cumsum)
    else:
      num_man += abs((-1)**(i+s) - prev_cumsum -a)
      prev_cumsum = (-1)**(i+s)
      #print(prev_cumsum)
  answer = min(answer, num_man)
  #print(num_man)
print(answer)
      
  

Measured memory_bytes: 14332
import java.io.*;
import java.util.*;
import java.util.regex.*;


public class Main {

	final static long MOD = 1000000007;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static long cnt=0;
	public static PrintWriter pw = new PrintWriter(System.out);
	public static void main(String[] args) throws Exception {
		solutionA(args);
		if(in!=null){
			in.close();
		}
		pw.flush();
		pw.close();
	}

	public static void solutionA(String[] args) throws Exception{

		int N = nextInt();
		int[] a = nextInts();

		int[] color = new int[9];
		for(int i=0;i<N;i++) {
			if(a[i]>3199) {
				color[8]++;
			}else {
				color[a[i]/400]++;
			}
		}
		int min = 0;
		for(int i=0;i<8;i++) {
			if(color[i]!=0) {
				min++;
			}
		}
		int max;
		if(color[8]==N) {
			min=1;
			max=N;
		}else {
			max = min+color[8];
		}
		pw.println(min+" "+max);
	}

	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}

}



Measured memory_bytes: 21332
# author:  Taichicchi
# created: 22.09.2020 12:19:17

import sys

from collections import Counter

N = int(input())

S = input()

e = [0]
w = [0]

for s in S:
    if s == "W":
        w += [w[-1] + 1]
        e += [e[-1]]
    elif s == "E":
        w += [w[-1]]
        e += [e[-1] + 1]

ans = 3 * (10 ** 5) + 1

for i in range(N):
    c = w[i]
    c += e[N] - e[i + 1]
    ans = min(c, ans)

print(ans)


Measured memory_bytes: 23788
#include <iostream>
#include <cstdio>
using namespace std;
const int MAX_N = 210;
const int MAX_T = 1005;
const int INF = 2*MAX_N*MAX_T;
int N,M,R;
int sea[MAX_N][MAX_N];
int land[MAX_N][MAX_N];
const int MAX_R = 1005;
int O[MAX_R];
int dp[MAX_R][MAX_N];
void show(char s) {
    printf("\n");
    if (s == 'L') {
        printf("Land\n");
        for (int i = 1; i <= N; i++) {
            for (int j = 1; j <= N; j++) {
                int n = land[i][j];
                if (n == INF) printf("INF ");
                else printf("%d ", n);
            }
            printf("\n");
        }
    } else if (s == 'S') {
        printf("Sea\n");
        for (int i = 1; i <= N; i++) {
            for (int j = 1; j <= N; j++) {
                int n = sea[i][j];
                if (n == INF) printf("INF ");
                else printf("%d ", n);
            }
            printf("\n");
        }
    }
}

int main(int argc, const char * argv[])
{
    while (true) {
        scanf("%d %d", &N, &M);  //町の番号は1~Nにする
        if (N == 0 && M == 0) break;
        for (int i = 1; i <= N; i++) {
            for (int j = 1; j <= N; j++) {
                if (i == j) {
                    sea[i][j] = land[i][j] = 0;
                } else {
                    sea[i][j] = land[i][j] = INF;
                }
            }
        }
        for (int i = 0; i < M; i++) {
            int x,y,t;
            char s;
            scanf("%d %d %d %c", &x, &y, &t, &s);
            if (s == 'L') {
                land[x][y] = land[y][x] = t;
            } else if (s == 'S'){
                sea[x][y] = sea[y][x] = t;
            }
        }
        scanf("%d", &R);
        
        for (int i = 0; i < R; i++) {
            scanf("%d", &O[i]);
        }
        
        for (int k = 1; k <= N; k++) {
            for (int i = 1; i <= N; i++) {
                for (int j = 1; j <= N; j++) {
                    land[i][j] = min(land[i][j], land[i][k] + land[k][j]);
                    sea[i][j] = min(sea[i][j], sea[i][k] + sea[k][j]);
                }
            }
        }
        //確認
        //show('L');
        //show('S');
        for (int i = 1; i <= N; i++) dp[0][i] = INF;
        dp[0][O[0]] = 0;
        
        
        for (int i = 1; i < R; i++) {
            for (int j = 1; j <= N; j++) {
                int minD = INF;
                for (int k = 1; k <= N; k++) {
                    if (j == k) {
                        minD = min(minD, dp[i-1][j] + land[O[i-1]][O[i]]);
                    } else {
                        minD = min(minD, dp[i-1][k] + land[O[i-1]][k] + sea[k][j] + land[j][O[i]]);
                    }
                    //printf("minD=%d\n",minD);
                }
                dp[i][j] = minD;
            }
        }
        int ret = INF;
        for (int i = 1; i <= N; i++) ret = min(ret, dp[R-1][i]);
        printf("%d\n", ret);
    }
    return 0;
}

Measured memory_bytes: 2352
N = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
ap = 0
ad = 0
for i in a:
    ap += b[i - 1]
    
for j in range(1, len(a)):
    
    if a[j] - a[j - 1] == 1:
            ad += c[a[j - 1] - 1]

print(ap + ad)

Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = "";

		while ((line = br.readLine()) != null) {
			if (line.length() > 1) {

				char[] nums = new char[10];
				int n, min, max;
				String minstr = "", maxstr = "";

				for (int i = 0; i < 8; i++) {
					n = Integer.parseInt(String.valueOf(line.charAt(i)));
					nums[n]++;
				}

				for (int i = 9; i >= 0; i--) {
					if (nums[i] > 0) {
						for (int j = 1; j <= nums[i]; j++) {
							maxstr += String.valueOf(i);
						}
					}
				}
				for (int i = 7; i >= 0; i--) {
					minstr += String.valueOf(maxstr.charAt(i));
				}
				max = Integer.valueOf(maxstr);
				min = Integer.valueOf(minstr);
				System.out.println(max - min);
			}

		}
	}
}

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

int main() {
  int a, b, N;
  cin >> N;
  int t[100001], x[100001], y[100001], z[100001];
  for (int i = 0; i < N; i++) cin >> t[i+1] >> x[i+1] >> y[i+1];
  t[0] = 0; x[0] = 0; y[0] = 0;

  for (int i = 0; i <= N; i++) z[i] = x[i] + y[i];
  for (int i = 0; i< N; i++) {
    a = abs(z[i+1] - z[i]);
    b = t[i+1] - t[i];
    if (b % 2 != a % 2 || a > b) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}

Measured memory_bytes: 5136
#include<cstdio>
#include<algorithm>
using namespace std;
inline int read()
{
	int s=0;
    char c=getchar();
    while(c<'0' || c>'9')c=getchar();
    while(c>='0'&&c<='9')s=(s<<1)+(s<<3)+c-48,c=getchar();
    return s;
}
inline bool cmp(int a,int b)
{
	return a>b;
}
int n,p,m,k[200005],a[200005];
int ans;
int main()
{
	n=read();  p=read();
	for(register int i=1;i<=n;i++)
	{
		a[i]=read();  k[a[i]]++;
	}
	sort(k+1,k+n+1,cmp);
	m=unique(a+1,a+n+1)-(a+1);
	if(m<=p){printf("0");return 0;}
	for(register int i=1;i<=p;i++)
		ans+=k[i];
	ans=n-ans;
	printf("%d",ans);
	return 0;
}

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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll A, B;
    cin >> A >> B;
    cout << std::max(0LL, A - 2 * B) << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner
 
fun main(args : Array<String>){
  val cin = Scanner(System.`in`)
  var n = cin.nextLong()
  var m = cin.nextLong()
  var res : Long
  if (n * 2L <= m){
    res = n
    m -= n * 2L
    res += m / 4L
  }
  else res = m / 2L
  println(res)
}

Measured memory_bytes: 21676
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int K,a;
  cin >>K;
  
  if(K%2==1){a=K/2*(K/2+1);}
  else if(K%2==0) {a=K/2*K/2;}
  
  cout << a<<endl;
}
  
  

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

using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)

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

    cout << ans <<"\n";

    return 0;
}

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

int main() {
  int N;
  cin>>N;
  int ai[N];
  int ans=0;
  int over=0;
  vector<bool> bi(8,true);
  for(int i=0;i<N;i++){
    cin>>ai[i];
  }
  for(int i=0;i<N;i++){
    if(ai[i]>=1 && ai[i]<=399 && bi[0]){
      ans++;
      bi[0]=false;
    } else if(ai[i]>=400 && ai[i]<=799 && bi[1]){
      ans++;
      bi[1]=false;
    } else if(ai[i]>=800 && ai[i]<=1199 && bi[2]){
      ans++;
      bi[2]=false;
    } else if(ai[i]>=1200 && ai[i]<=1599 && bi[3]){
      ans++;
      bi[3]=false;
    } else if(ai[i]>=1600 && ai[i]<=1999 && bi[4]){
      ans++;
      bi[4]=false;
    } else if(ai[i]>=2000 && ai[i]<=2399 && bi[5]){
      ans++;
      bi[5]=false;
    } else if(ai[i]>=2400 && ai[i]<=2799 && bi[6]){
      ans++;
      bi[6]=false;
    } else if(ai[i]>=2800 && ai[i]<=3199 && bi[7]){
      ans++;
      bi[7]=false;
    } else if(ai[i]>=3200){
      over++;
    }
  }
  if(ans==0){
    cout<<1<<" "<<over<<endl;
  }else{
    cout<<ans<<" "<<ans+over<<endl;
  }
}

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

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

int main() {
  ll h, n;
  cin >> h >> n;
  vector<ll> a(n), b(n);
  REP(i, n) { cin >> a[i] >> b[i]; }
  const ll INF = 1e18;
  vector<ll> dp(h + 1, INF);
  dp[0] = 0;
  REP(i, h) REP(j, n) {
    ll nxt = min(i + a[j], h);
    chmin(dp[nxt], dp[i] + b[j]);
  }
  cout << dp[h] << endl;
}

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

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

    string A[n];
    string B[m];

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

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

    bool exist = false;
    for(int y = 0; y <= n-m; y++){
        for(int x = 0; x <= n-m; x++){

            bool match = true;
            for(int i = 0; i < m; i++){
                for(int j = 0; j < m; j++){
                    if(A[y+i][x+j] == B[i][j]){
                        continue;
                    }
                    else{
                        match = false;
                        //break;
                    }
                }
            }

            if(match == true){
                exist = true;
                break;
            }

        }
    }

    if(exist == true){
        printf("Yes\n");
    }
    else{
        printf("No\n");
    }

    return 0;
}

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

using namespace std;

#define long long long
#define INF ((long) 2e18)
#define MOD ((long) (1e9 + 7))
#define umap unordered_map

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

    long t = 1;
    //cin >> t;

    while (t--) {
        long n;
        string s;
        cin >> n >> s;

        if (n % 2 != 0) puts("No");
        else if (s.substr(0, n/2) != s.substr(n/2, n/2)) puts("No");
        else puts("Yes");
    }
}


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

using namespace std;

#define forn(i, x, n) for (int i = int(x); i <= int(n); ++i)
#define for1(i, n, x) for (int i = int(n); i >= int(x); --i)
#define F first
#define S second
#define pb push_back

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

const int N = 2e6 + 1;
const ll INF = 1e18 + 9;
const int B = 1e9 + 7;

int n = 7;
int a[N];

int f() {
    vi v(8);
    forn(i, 1, 7)
        v[i] = a[i];
    forn(i, 1, n / 2) {
        vi t(v.size() - 2);
        //forn(i, 1, v.size() - 1) cerr << v[i] << " ";cerr << "\n";
        forn(j, 1, t.size() - 1)
            t[j] = v[j] + v[j + 1] + v[j + 2]
                - min(v[j], min(v[j + 1], v[j + 2])) - max(v[j], max(v[j + 1], v[j + 2]));
        v = t;
    }
    forn(i, 1, 7) cout << a[i] << " "; cout << ":" << v[1] << "\n";
    return v[1];
}

int u[N];

int main() {
    #ifdef black
    freopen("in", "r", stdin);
    //freopen("out", "w", stdout);
    #endif // black
    ios_base :: sync_with_stdio(0);
    cin.tie(0);
/*
    forn(i, 1, n) a[i] = i;
    do {
    } while (next_permutation(a + 1, a + 8));*/

    int n, k;
    cin >> n >> k;
    if (k == 1 || k == 2 * n - 1)
        cout << "No\n";
    else {
        cout << "Yes\n";
        if (n == 2) {
            cout << "1\n2\n3\n";
            return 0;
        }
        a[n] = k;
        u[k] = 1;
        a[n - 1] = k - 1;
        u[k - 1] = 1;
        a[n + 1] = k + 1;
        u[k + 1] = 1;
        if (k > 2) {
            a[n - 2] = k - 2;
            u[k - 2] = 1;
        }
        if (k + 2 <= 2 * n - 1) {
            a[n + 2] = k + 2;
            u[k + 2] = 1;
        }
        int x = 1;
        forn(i, 1, 2 * n - 1) {
            if (a[i]) continue;
            while (x <= 2 * n - 1 && u[x]) ++x;
            a[i] = x++;
        }
        forn(i, 1, 2 * n - 1)
            cout << a[i] << "\n";
        //cerr << f() << "\n";
    }

    return 0;
}


Measured memory_bytes: 5632
#include<iostream>
#include<algorithm>
using namespace std;
 
int main(void){
    int n;
    cin >> n;
    for(int i=0; i<n; i++){
        int a[3];
        cin >> a[0] >> a[1] >> a[2];
        sort(a, a+3);
        if(a[0]*a[0]+a[1]*a[1]==a[2]*a[2])
            cout << "YES" << endl;
        else
            cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 1168