akhauriyash/Code-Regression huggingface dataset:
//g++ -std=c++14 test.cpp -o test.out
//問題URL
//https://atcoder.jp/contests/abc154/tasks/abc154_f

//ポイント：
//二項係数を考えるときは
//パスカルの三角形ベースで考えてみるのも良さそう

#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <stack>
#include <map> 
#include <unordered_map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (1LL<<60);
const int INF_INT = 2147483647-1e6-1;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;

//https://github.com/atcoder-live/library/blob/master/mint.cpp
#define LL long long int
struct mint {
  LL x; 
  mint(LL x=0):x((x%mod+mod)%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(LL t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};
 
struct combination {
  vector<mint> fact, ifact;//factに階乗を計算、ifactはその各々に対する逆元
  combination(LL n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (LL i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (LL i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(LL n,LL k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

LL r1,c1,r2,c2;

mint ans = 0;

void solve(){
	vector<mint> pow2(2000001,1);
	for(int i=1;i<=2000000;i++) pow2[i] = pow2[i-1]*mint(2);

	combination c(2000001);

	auto square = [&](LL x,LL y){
		return c(x+y+1,y)+c(x+y+1,y+1)-mint(1);
	};

	ans = square(r2,c2)-(square(r1-1,c2)+square(c1-1,r2)-square(r1-1,c1-1));
}

int main(){
    cin >> r1 >> c1 >> r2 >> c2;

    solve();

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

Measured memory_bytes: 47104
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cout << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cout<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 300010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
///////////////////////////////////////////////////////////////////////////////////////////////////

int N, M;
vi G[MAX_N];
int dp[MAX_N];

int loop(int v) {
	if(dp[v] != -1) return dp[v];
	int res = 0;
	rep(i, 0, sz(G[v])) {
		int n = G[v][i];
		MAX(res, loop(n) + 1);
	}
	return dp[v] = res;
}

void solve() {
	cin >> N >> M;
	rep(i, 0, M) {
		int a, b; cin >> a >> b; a--; b--;
		G[a].pb(b);
	}
	memset(dp, -1, sizeof(dp));
	int res = 0;
	rep(i, 0, N) {
		MAX(res, loop(i));
	}
	cout << res << "\n";
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
	srand((unsigned int)time(NULL));
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}



Measured memory_bytes: 14336
# -*- coding: utf-8 -*-
A = list(map(int, input().split()))
max = 0

ans = [0,0,0]
for i in range(0,3):
    diff = 0
    for j in range(0,3):
        diff += abs(A[i] - A[j])
    ans[i] = diff

print (min(ans))

Measured memory_bytes: 3060
import java.util.*;
import java.io.*;

public class Main 
{ 

	 static FastReader sc=new FastReader(); 
	  public static void main(String[] args) 
    {
    	String s=s();
    	int c=0,max=0;
    	for(int i=0;i<3;i++){
    	    if(s.charAt(i)=='R'){
    	        c++;
    	    }
    	    else{
    	        if(c>max)
    	        max=c;
    	        c=0;
    	    }
    	    
    	}
    	if(c>max)
    	max=c;
    	System.out.println(max);
        
        	
        	
			
	
	}    	
    	
   static void input(int A[]) {
	   for(int i=0;i<A.length;i++) {
		   A[i]=sc.nextInt();
	   }
   }
     static int i() {
    	 return sc.nextInt();
     }
     static String s() {
    	 return sc.next();
     }
     static long l() {
    	 return sc.nextLong();
     }
     public static String rev(String str){  
    	    char ch[]=str.toCharArray();  
    	    String rev="";  
    	    for(int i=ch.length-1;i>=0;i--){  
    	        rev+=ch[i];  
    	    }  
    	    return rev;  
    	}  
        static void shuffleArray(int[] arr){
        int n = arr.length;
        Random rnd = new Random();
        for(int i=0; i<n; ++i){
            int tmp = arr[i];
            int randomPos = i + rnd.nextInt(n-i);
            arr[i] = arr[randomPos];
            arr[randomPos] = tmp;
        }   
}
  
        
        
    static class FastReader 
    { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() 
        { 
            br = new BufferedReader(new
                     InputStreamReader(System.in)); 
        } 
  
        String next() 
        { 
            while (st == null || !st.hasMoreElements()) 
            { 
                try
                { 
                    st = new StringTokenizer(br.readLine()); 
                } 
                catch (IOException  e) 
                { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() 
        { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() 
        { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() 
        { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() 
        { 
            String str = ""; 
            try
            { 
                str = br.readLine(); 
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    } 
} 





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

int main()
{
    int a[10] , i = 0;
	
    while (i < 10){
		cin>>a[i];
		i++;
    }
	
    sort(a , a + 10);
	
	while (--i > 6){
		cout << a[i] << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1176
def main():
    N = int(input())
    s = input()
    # c = ["WS", "SW", "SS", "WW"]
    c = ["SW", "WS", "SS", "WW"]
    ok = False
    for tmp in c:
        ans = tmp
        for i in range(1, N):
            if s[i] == "o":# oの時
                if ans[i-1] == "S" and ans[i] == "S":
                    ans += "S"
                elif ans[i-1] == "W" and ans[i] == "S":
                    ans += "W"
                elif ans[i-1] == "S" and ans[i] == "W":
                    ans += "W"
                elif ans[i-1] == "W" and ans[i] == "W":
                    ans += "S"
            else:# xの時
                if ans[i-1] == "S" and ans[i] == "S":
                    ans += "W"
                elif ans[i-1] == "W" and ans[i] == "S":
                    ans += "S"
                elif ans[i-1] == "S" and ans[i] == "W":
                    ans += "S"
                elif ans[i-1] == "W" and ans[i] == "W":
                    ans += "W"
    
        if ans[0] == ans[-1]:
            if ans[0] == "S":
                if s[0] == "o":
                    if (ans[-2] == "S" and ans[1] == "S") or (ans[-2] == "W" and ans[1] == "W"):
                        ok = True
                else:
                    if (ans[-2] == "S" and ans[1] == "W") or (ans[-2] == "W" and ans[1] == "S"):
                        ok = True
            else:
                if s[0] == "o":
                    if (ans[-2] == "S" and ans[1] == "W") or (ans[-2] == "W" and ans[1] == "S"):
                        ok = True
                else:
                    if (ans[-2] == "S" and ans[1] == "S") or (ans[-2] == "W" and ans[1] == "W"):
                        ok = True
        if ok:
            print(ans[:-1])
            # print(len(ans))
            break
    if not ok:
        print(-1)

if __name__ == "__main__":
    main()

Measured memory_bytes: 3700
//! Framework <https://github.com/vain0x/procon>

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

use std::collections::*;

pub struct Scan(Box<dyn Iterator<Item = &'static str>>); // '

impl Scan {
    fn new() -> Self {
        let mut buf = String::new();
        let read_line = move || {
            std::io::stdin().read_line(&mut buf).unwrap();
            Box::leak(buf.split_off(0).into_boxed_str()).split_whitespace()
        };
        Scan(Box::new(std::iter::repeat_with(read_line).flatten()))
    }

    pub fn word<T: std::str::FromStr>(&mut self) -> T {
        self.0.next().unwrap().parse().ok().unwrap()
    }

    pub fn list<T: std::str::FromStr>(&mut self, len: usize) -> Vec<T> {
        std::iter::repeat_with(|| self.word()).take(len).collect()
    }
}

fn main() {
    let mut scan = Scan::new();

    let N = scan.word::<usize>();
    let M = N * N;

    let P = scan.list::<usize>(M);

    let mut index = vec![vec![M; N]; N];
    let mut u = 0;
    for y in 0..N {
        for x in 0..N {
            index[y][x] = u;
            u += 1;
        }
    }

    let mut g = vec![vec![]; M];
    for y in 0..N {
        for x in 0..N {
            let u = index[y][x];

            for &(dy, dx) in &[(1, 0), (0, -1), (-1, 0), (0, 1)] {
                let (y2, x2) = (y as isize + dy, x as isize + dx);
                if y2 < 0 || x2 < 0 || y2 >= N as isize || x2 >= N as isize {
                    continue;
                }
                let (y2, x2) = (y2 as usize, x2 as usize);

                let v = index[y2][x2];
                g[u].push(v);
                g[v].push(u);
            }
        }
    }

    let mut hated = vec![M; M];
    for y in 0..N {
        for x in 0..N {
            let u = index[y][x];
            hated[u] = y.min(x).min(N - 1 - y).min(N - 1 - x);
        }
    }

    let mut q = VecDeque::new();
    let mut occupied = vec![1; M];
    let mut total = 0;

    for p in P {
        let u = p - 1;

        total += hated[u];
        occupied[u] = 0;

        q.clear();
        q.push_back((u, hated[u]));

        while let Some((u, d)) = q.pop_front() {
            let d = d + occupied[u];

            for i in 0..g[u].len() {
                let v = g[u][i];

                if hated[v] > d {
                    hated[v] = d;
                    q.push_back((v, d));
                }
            }
        }
    }

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


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

int main() {
  int N,D,X;
  cin >> N >> D >> X;
  int sum=0,suma=0;
  for(int i=0;i<N;i++) {
    int a;
    cin >> a;
    int j=0;
    while(j*a+1<=D) {
      sum++;
      j++;
    }
    //cout << sum << endl;
  }
  cout << sum+X << endl;
}


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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
    int a,b;cin>>a>>b;
    if(b%a==0)cout<<a+b<<endl;
    else cout<<b-a<<endl;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define x first
#define y second
#define gcd(x, y) __gcd((x), (y))
using namespace std;

using i64 = long long;
using f64 = double;
using pii = pair<int, int>;

const int N = 1e5 + 5;

i64 a[N], b[N], c[N];

int n;
i64 sp, sn, t;

int main() {
#ifdef HOME
	freopen("atc.in", "r", stdin);
	freopen("atc.out", "w", stdout);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	
	cin >> n;	
	for (int i = 0; i < n; ++i)
		cin >> a[i];
	for (int i = 0; i < n; ++i)
		cin >> b[i];

	for (int i = 0; i < n; ++i)
		c[i] = a[i] - b[i];

	for (int i = 0; i < n; ++i) {

		if (c[i] < 0) {
			c[i]-= c[i] % 2;
			sn-= c[i]; }
		else
			sp+= c[i]; }

	if (sn - 2 * sp >= 0)
		cout << "Yes\n";
	else
		cout << "No\n";

	return 0; }


Measured memory_bytes: 512
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int main(){
	int n,k;
	cin>>n>>k;
	vector<ll> a(n);
	rep(i,n)cin>>a[i];
	ll ans = INF;
	for(int bit = 0; bit<(1<<n); ++bit){
		vector<bool> look(n,false);
		int cnt = 0;
		rep(i,n){
			if(bit & (1<<i)){
				cnt++;
				look[i] = true;
			}
		}
		if(cnt<k)continue;
		ll e_ans = 0LL;
		ll e_max = 0LL;
		rep(i,n){
			if(look[i]){
				if(e_max < a[i]){e_max = a[i]; continue;}
				e_ans += e_max-a[i]+1LL;
				e_max++;
			}else{
				e_max = max(e_max, a[i]);
			}
		}
		ans = min(ans, e_ans);
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
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; }

#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;

int D;
vector<int> c;
vector<vector<int>> s;

int compute_score(vector<int> &out){
  int score = 0;
  vector<int> last(26, 0);
  REP(d, out.size()){
    last[out[d]] = d+1;
    score += s[d][out[d]];
    REP(i, 26){
      score -= (d+1-last[i])*c[i];
    }
  }
  return score;
}

int evalute(vector<int> &out, int k){
  int score = 0;
  vector<int> last(26, 0);
  REP(d, out.size()){
    last[out[d]] = d+1;
    score += s[d][out[d]];
    REP(i, 26){
      score -= (d+1-last[i])*c[i];
    }
  }
  FOR(d, out.size(), min((int)out.size()+k, D)){
    REP(i, 26){
      score -= (d+1-last[i])*c[i];
    }
  }
  return score;
}

vector<int> solve(int k){
  vector<int> out;
  REP(_, D){
    int max_score = -INF;
    int best_i = 0;

    REP(i, 26){
      out.emplace_back(i);
      int score = evalute(out, k);
      if(chmax(max_score, score)){
        best_i = i;
      }
      out.pop_back();
    }
    out.emplace_back(best_i);
  }
  return out;
}

signed main() {
  cin >> D;

  c.resize(26);
  REP(i, 26) cin >> c[i];

  s = vector<vector<int>>(D, vector<int>(26));
  REP(i, D) REP(j, 26) cin >> s[i][j];


  int max_score = -INF;
  vector<int> ans;
  REP(k, 27){
    vector<int> tmp = solve(k);

    int score = compute_score(tmp);
    if(chmax(max_score, score)) ans = tmp;
  }

  REP(i, ans.size()){
    cout << ans[i]+1 << "\n";
  }

  return 0;
}

Measured memory_bytes: 3692
/*
___ is a raging sadist.
*/

//Destroy all WA at test 2

#include <bits/stdc++.h>
#define fastio()                  \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0)
#define pb push_back
#define show(x) cout << (#x) << " : " << x << endl;
#define ll long long
#define ld long double
#define pow power
#define mp make_pair
#define ff first
#define ss second
#define pii pair<ll, ll>
#define sq(x) ((x) * (x))
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define For(i,a,b) for(int (i)=(a);(i) < (b); ++(i))
#define endl "\n"
#define PI 3.14159265
const ll MOD = 1000 * 1000 * 1000 + 7;
const ll MOD1 = 998244353;
const ll INF     = 1ll*1000*1000*1000*1000*1000*1000 + 7; 
using namespace std;

ll power(ll x, ll y) 
{ 
   ll res = 1;      
  
   
    while (y > 0) 
    { 
       
        if (y & 1) 
            res = (long long)(res*x); 
  

        y = y>>1; 

        if (x<=100000000)
        x = (long long)(x*x);

        //cout<<x<<'\n'; 
    } 
    return res; 
} 






int main()
{

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

fastio();

ll n;
cin>>n;

ll rem=n%10;

if (rem==3)
cout<<"bon";
else if(rem==0||rem==1||rem==6||rem==8)
cout<<"pon";
else
cout<<"hon";

return 0;
}

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

namespace ConsoleApp3 {
    class Program {
        static void Main(string[] args) {
            var X = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            int A = X[0];
            int B = X[1];

            if (A <= 9 && B <= 9) {
                Console.WriteLine(A * B);
            } else {
                Console.WriteLine(-1);
            }

        }
    }
}


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

using namespace std;

int main()
{
    #ifdef LOCAL_EXEC
    #else
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #endif // LOCAL_EXEC
    long long int a,v,b,w,t,i;
    cin>>a>>v;
    cin>>b>>w;
    cin>>t;
   bool ok=false;
   if(b>a){
    if(a+t*v>=b+t*w)
        cout<<"YES";
    else
        cout<<"NO";
   }
   else if(b<a){
    if(a-t*v<=b-t*w)
        cout<<"YES";
    else
        cout<<"NO";
   }
    return 0;
}


Measured memory_bytes: 3640
table_prime_numbers = [True for _ in range(10 ** 5)]
table_2017_numbers = [0 for _ in range(10 ** 5)]
table_2017_numbers_acm = [0 for _ in range(10 ** 5)]

def init_tables():
  table_prime_numbers[0] = table_prime_numbers[1] = False
  for i in range(2, 10 ** 5):
    if table_prime_numbers[i]:
      for j in range(i * 2, 10 ** 5, i):
        table_prime_numbers[j] = False
      if table_prime_numbers[(i + 1) // 2]:
        table_2017_numbers[i] = 1
  
  for i in range(2, 10 ** 5):
    table_2017_numbers_acm[i] = table_2017_numbers_acm[i - 1] + table_2017_numbers[i]
      
  return

def cumul(n):
  return table_2017_numbers_acm[n]

def result(l, r):
  return cumul(r) - cumul(l - 1)

def main():
  q = int(input())
  
  for _ in range(q):
    l, r = map(int, input().split())
    print(result(l, r))

  return

if __name__ == "__main__":
  init_tables()
  main()


Measured memory_bytes: 8088
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		List<int[]> list = new ArrayList<>();
		for(int i=0;i<n;i++) {
			int[] tmp = {in.nextInt(),in.nextInt()};
			list.add(tmp);
		}
		list.sort((e1,e2)->-e2[1]+e1[1]);
		long now = 0;
		boolean success = true;
		for(int i=0;i<n;i++) {
			now += list.get(i)[0];
			if(now>list.get(i)[1]) {
				success = false;
				break;
			}
		}
		System.out.println(success?"Yes":"No");
		in.close();

	}

}


Measured memory_bytes: 107872
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define ALL(v) (v).begin(), (v).end()
#define LENGTHOF(x) (sizeof(x) / sizeof(*(x)))
#define AFILL(a, b) fill((int*)a, (int*)(a + LENGTHOF(a)), b)
#define SQ(x) ((x)*(x))
#define Mod(x, mod) (((x)+(mod)%(mod))
#define MP make_pair
#define PB push_back
#define Fi first
#define Se second
#define INF (1<<29)
#define EPS 1e-10
#define MOD 1000000007

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

int N;

int judge(vector<P> a, vector<P> B){
  int p = a.size();
  vector<P>b = B;
  //  rep(i, p) cout << b[i].first << " " << b[i].second << " " ; cout << endl;
  for(int i=1;i<p;i++){
    b[i].first -= b[0].first;
    b[i].second -= b[0].second;
  }

  b[0].first -= b[0].first;
  b[0].second -= b[0].second;
  rep(i,4){
    rep(j,p){
      int tmp = b[j].first;
      b[j].first = b[j].second;
      b[j].second = -1*tmp;
    }
    //    rep(j, p) cout << b[j].first << " " << b[j].second << " " ; cout << endl;
    if(a == b) return 1;
  }
  b = B;
  reverse(b.begin(), b.end());
  for(int i=1;i<p;i++){
    b[i].first -= b[0].first;
    b[i].second -= b[0].second;
  }

  b[0].first -= b[0].first;
  b[0].second -= b[0].second;
  rep(i,4){
    rep(j,p){
      int tmp = b[j].first;
      b[j].first = b[j].second;
      b[j].second = -1*tmp;
    }
    if(a == b) return 1;
  }
  return 0;
}

int main(){
  while(scanf("%d", &N) && N){
    int m,x,y;
    vector<P>origin;
    scanf("%d", &m);
    rep(i,m){
      scanf("%d%d", &x, &y);
      origin.push_back(P(x,y));
    }
    for(int i=1;i<m;i++){
      origin[i].first -= origin[0].first;
      origin[i].second -= origin[0].second;
    }
    origin[0].first -= origin[0].first;
    origin[0].second -= origin[0].second;

    rep(i,N){
      scanf("%d",&m);
      vector<P>line;
      rep(j,m){
	scanf("%d%d", &x, &y);
	line.push_back(P(x,y));
      }
      //      rep(j, origin.size()) cout << origin[j].first << " " <<  origin[j].second << " "; cout << endl;
      //      rep(j, line.size()) cout << line[j].first << " " <<  line[j].second << " "; cout << endl;
      if(origin.size() == line.size() && judge(origin, line)){
	printf("%d\n", i+1);
      }
    }
    puts("+++++");
  }
  return 0;
}

Measured memory_bytes: 1200
'use strict';
const main = input => {
  const x = input[0].split(' ').map(val => parseInt(val)), n = x[0], k = x[1];
  input.shift();
  const h = input.map(val => parseInt(val, 10));
  h.pop();
  h.sort((x,y) => x-y);
  // console.log(h);
  let min = 10e9;
  for(let i=0; i<n-k+1; i++){
    if (min > h[i+k-1] - h[i]) min = h[i+k-1] - h[i];
  }
  console.log(min);
  
}
main(require("fs").readFileSync("/dev/stdin", "utf8").split('\n'));

Measured memory_bytes: 28864
#include<iostream>
using namespace std;
int main() {

	int n, h[100], ans = 0;
	cin >> n;
	for (int i = 0; i != n; i++)cin >> h[i];

	bool trg = false,trgend=false;

	for (;;) {
		
		trg = false;
		trgend = true;

		for (int i = 0; i != n; i++) {

			if (h[i] != 0) {
				trg = true;
				trgend = false;
			}

			if (trg == true) {
				if (h[i] == 0) {
				ans++;
				trg = false;
				}
				else {
					h[i]--;
				}
			}
		}

		if (trg == true) {
			trg = false;
			ans++;
		}

		if (trgend) {
			cout << ans << endl;
			break;
		}

	}

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>


typedef struct node {long int item; struct node *next;} link;

int count =0;
int dcount=0;
link *insert(link *nxt,long int item){
 link *A;
 A =malloc(sizeof(link));
 A->item = item;
 A-> next =nxt;
 return A;
}


link *deleteFirst(link *B){
 link *A;
 A=B->next;
 free(B);
 return A;
}


link *delete(link *B,long int key){
 link *A,*C;
 A=B;
 C=B;
 int flag;
 flag=0;
 if(B->item == key){
 B=deleteFirst(B);
 C=B;
 flag=1;
}else{
 while(B ->next != NULL && B->item != key){  
 A=B; 
 B = B ->next;
 }
 
 if (B->item==key){
 A->next=A->next->next;
 free(B);
flag=1;
}}
if(flag==0){dcount++;}
 return C;
}




int main(void){
int n;
long int B;
char A[50];
char *s1 = "insert";
char *s2 = "delete";
char *s3 = "deleteFirst";
char *s4 = "deleteLast";

link *head;
 head =NULL;


scanf("%d",&n);

for (int i=0;i<n;i++){
 scanf("%s",A);

 if(strcmp(s1,A)==0){
 scanf("%ld",&B);
  head=insert(head,B);
 }
 if(strcmp(s2,A)==0){
  scanf("%ld",&B);
  head=delete(head,B);
  count++;
 }
 if(strcmp(s3,A)==0){
  head=deleteFirst(head);
  count++;
 }
 if(strcmp(s4,A)==0){
  count++;
 }
}


printf ("%ld",head->item);
link *First;
First = head->next;
int l=n-(2*count)-1+dcount;
  for(int i=0;i<l;i++){
 printf(" %ld",First->item);
 First = First->next;
}

 printf("\n");
return 0;
}

Measured memory_bytes: 32928
#include <iostream>
#include <map>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

map<P, int> a; //正と正
map<P, int> b; //正と負
ll c;          //0と整数
ll d;          //整数と0
ll e;          //0と0
int n;
const ll mod = 1e9 + 7;
ll ans = 1;

ll f(ll a, ll x)
{
    ll res = 1;
    while (x > 0)
    {
        if (x & 1)
            res = res * a % mod;
        a = a * a % mod;
        x >>= 1;
    }
    return res;
}

ll gcd(ll a, ll b)
{
    return b == 0 ? a : gcd(b, a % b);
}

int main()
{
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        ll A, B;
        cin >> A >> B;

        if (A == 0 && B == 0)
        {
            e++;
        }
        else if (A == 0)
        {
            c++;
        }
        else if (B == 0)
        {
            d++;
        }
        else if (A > 0 && B > 0)
        {
            ll h = gcd(A, B);
            a[P(A / h, B / h)]++;
        }
        else if (A < 0 && B < 0)
        {
            A = -A;
            B = -B;
            ll h = gcd(A, B);
            a[P(A / h, B / h)]++;
        }
        else
        {
            if (A < 0)
                A = -A;
            if (B < 0)
                B = -B;

            ll h = gcd(A, B);
            b[P(A / h, B / h)]++;
        }
    }

    for (auto itr = a.begin(); itr != a.end(); ++itr)
    {
        ll x = itr->first.first;
        ll y = itr->first.second;
        ll z = itr->second;
        ll R = (f(2, z) + f(2, b[P(y, x)]) - 1 + mod) % mod;
        ans = ans * R % mod;
    }

    for (auto itr = b.begin(); itr != b.end(); ++itr)
    {

        ll x = itr->first.first;
        ll y = itr->first.second;
        ll z = itr->second;
        if (a[P(y, x)] == 0)
        {
            ans = ans * f(2, z) % mod;
        }
    }

    ll tmp = (f(2, c) + f(2, d) - 1 + mod) % mod;

    ans = ans * tmp % mod;

    ans = (ans + e) % mod;

    cout << (ans - 1 + mod) % mod << endl;
}

Measured memory_bytes: 28452
#include <iostream>
#include <string>
using namespace std;
int main(void){
    // Your code here!
    int count=0;
    string S;
    
    cin >> S;
    int len = S.size();
    
    for(int i=0;i<len/2;i++)
    if(S[i]!=S[len-i-1])
    count++;
    
    cout << count << endl;
    
}


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

using namespace std;
using ll = int64_t;
using P = std::pair<int, int>;

const int INF = 1e8;

int main() {
    ios::sync_with_stdio(false);
    string t;
    cin >> t;

    for(int i = 0; i < t.size(); i++) {
        for(int j = i + 1; j < t.size(); j++) {
            if(t[i] == 'C' and t[j] == 'F') {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }

    cout << "No" << endl;
}


Measured memory_bytes: 256
<?php
$N = fgets(STDIN);
$A = explode(" ",fgets(STDIN));
$count=0;
$result=0;
$flug=0;
while($flug == 0){
  $count=0;
  foreach($A as $key => $v){
    if($v%2==0){
      $count++;
      $A[$key]=$v/2;
    }
  }
  
  if($count==$N){
    $result++;
  }else{
    $flug=1;
  }
}
print($result);

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

int b[101],s;
int main()
{
	int n,k;
	cin>>n>>k;
	int p;
	while(s!=k)
	{
		cin>>p;
		int a[p+1];
		for(int i=1;i<=p;i++)
		{
			cin>>a[i];
			b[a[i]]++;
		}
		s++;
	}
	
	int t=0;
	for(int i=1;i<=n;i++)
	{
		if(b[i]==0)
		{
			t++;
		}
	}
	cout<<t;
	return 0;
}

Measured memory_bytes: 3588
#include<stdio.h>
void func(int,int);
int n,m,cnt,sum;
int main(void)
{
	while(1){
		int i,j;
		scanf("%d %d",&n,&m);
		if(n==0&&m==0) break;
		cnt=0; sum=0;
		func(0,0);
		printf("%d\n",cnt);
	}
	return 0;
}
void func(int nn,int x)
{
	int i;
	if(nn==n&&sum==m) cnt++;
	else{
		for(i=x;i<10;i++){
			sum+=i; func(nn+1,i+1);
			sum-=i;
		}
	}	
}

Measured memory_bytes: 2692
#include <bits/stdc++.h>
using namespace std;
const int maxn=1e5+10,mod=998244353,inf=0x3f3f3f3f;
int n,m,k,t,pl[maxn],pr[maxn],id1[maxn],id2[maxn];
bool vis[maxn];
int main()
{
    int i,j;
    scanf("%d",&n);
    for(i=1;i<=n;i++)
        scanf("%d%d",&pl[i],&pr[i]),id1[i]=id2[i]=i;
    sort(id1+1,id1+n+1,[](int x,int y){return pl[x]>pl[y];});
    sort(id2+1,id2+n+1,[](int x,int y){return pr[x]<pr[y];});
    long long ret1=0,ret2=0;
    int pos=0;
    for(i=1;i<=n;i++)
    {
        if(pl[id1[i]]>pos)
            ret1+=pl[id1[i]]-pos,pos=pl[id1[i]];
        if(pr[id2[i]]<pos)
            ret1+=pos-pr[id2[i]],pos=pr[id2[i]];
    }
    ret1+=abs(pos);
    pos=0;
    for(i=1;i<=n;i++)
    {
        if(pr[id2[i]]<pos)
            ret2+=pos-pr[id2[i]],pos=pr[id2[i]];
        if(pl[id1[i]]>pos)
            ret2+=pl[id1[i]]-pos,pos=pl[id1[i]];
    }
    ret2+=abs(pos);
    printf("%lld\n",max(ret1,ret2));
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int N , M;
	cin >> N >> M;
	int P = max(N , M);
	int R;
	cin >> R;
	if (R % P == 0)
	{
		cout<<R/P<<endl;
	}
	else
	{
		cout<<R/P + 1<<endl;
	}
}

Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <numeric>
#include <tuple>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr long long MOD = 1000000000 + 7;
constexpr int INF = 2000000000;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);

int a[5011];
bitset<5011> dp[5011];

int main(){
	int n, k;
	cin >> n >> k;
	for (int i = 0; i<n; i++) cin >> a[i];
	sort(a, a + n);
	int left = 0, right = n - 1;
	int ans = n;
	while (left <= right){
		int mid = (left + right) >> 1;
		dp[0].reset();
		dp[0].set(0, 1);
		for (int i = 1; i <= n; i++){
			dp[i] = dp[i - 1];
			if (i - 1 != mid&&a[i - 1] <= k) dp[i] |= (dp[i - 1] << a[i - 1]);
		}
		bool pos = 0;
		for (int i = max(0, k - a[mid]); i < k; i++)
		{
			pos |= dp[n][i];
		}
		if (pos)
		{
			ans = mid;
			right = mid - 1;
		}
		else
		{
			left = mid + 1;
		}
	}
	cout << ans << '\n';
}

Measured memory_bytes: 3328
#define LOCAL
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;
mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x; }


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int T;
    cin >> T;
    
    unordered_map<string,int> mp;
    for(int i = 0 ; i < T ;i++){
        string t;
        cin >> t;
        mp[t]++;
    }
    
    printf("AC x %d\n",mp[string("AC")]);
    printf("WA x %d\n",mp[string("WA")]);
    printf("TLE x %d\n",mp[string("TLE")]);
    printf("RE x %d\n",mp[string("RE")]);

  return 0;
}


Measured memory_bytes: 3760
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <string>
#include <cstring>
#include <complex>
#include <ctime>
#include <cstdlib>

using namespace std;

inline int to_int(string s) {int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string to_str(T x) {ostringstream sout; sout << x; return sout.str();}

typedef long long ll;
const int INF = 1 << 30;

int main()
{
	int n;

	while(cin >> n, n)
	{
		vector<int> T;
		int res = 0, num, up = n-1, low = 0;
		for(int i = 0; i < n; i++)
		{
			int a; cin >> a;
			T.push_back(a);
		}
		cin >> num;

		while( low <= up )
		{
			int mid = (up + low) / 2;
			res++;
			if(T[mid] > num)
			{
				up = mid-1;
			}
			else if(T[mid] < num)
			{
				low = mid+1;
			}
			else
			{
				break;
			}
		}
		
		cout << res << endl;
	}
}

Measured memory_bytes: 1216
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ii pair<ll,ll>
#define iii pair<ll,ii>
#define endl '\n'

const int MOD=1000000007;

long long qexp(long long b,long long p,int m){
    long long res=1;
    while (p){
        if (p&1) res=(res*b)%m;
        b=(b*b)%m;
        p>>=1;
    }
    return res;
}


ll n,k;
ll val[100005];

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

	cin>>n>>k;
	
	ll ans=0;
	
	
	for (int x=1;x<=k;x++) val[x]=x;
	
	for (int x=1;x<=k;x++){
		for (int y=x*2;y<=k;y+=x) val[y]=(val[y]-val[x]+MOD)%MOD;
	}
	
	//for (int x=1;x<=k;x++) cout<<x<<" "<<val[x]<<endl;
	
	for (int x=1;x<=k;x++){
		ans+=(val[x]*qexp(k/x,n,MOD))%MOD;
		ans%=MOD;
	}
	
	cout<<ans;
	
}

Measured memory_bytes: 4432
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include <time.h>
typedef long long ll;
typedef long double ld;
#define INF (1LL<<60)
/*swap 交換*/
void swap(ll *a, ll *b){ll c;c=*b;*b=*a;*a=c;}
/*2つのうち大きい数を返す*/
ll max2(ll a,ll b){return a>=b?a:b;}
/*2つのうち小さい数を返す*/
ll min2(ll a,ll b){return a>=b?b:a;}
/*絶対値*/
ll ABS(ll a){return a>=0?a:(-a);}
typedef struct{
    ll aa;
    ll bb;
}frequent;
// 小大
int compare(const void *a, const void *b){return *(ll *)a - *(ll *)b;}

int main(void){
    ll n,i;
    scanf("%lld",&n);
    ll t[n+1],x[n+1],y[n+1];
    t[0]=0;
    x[0]=0;
    y[0]=0;
    for(i=1;i<n+1;i++){
        scanf("%lld%lld%lld",&t[i],&x[i],&y[i]);
    }
    for(i=1;i<n+1;i++){
        if( ( ABS(x[i]-x[i-1])+ABS(y[i]-y[i-1]) > t[i]-t[i-1]) || ( t[i]-t[i-1]-(ABS(x[i]-x[i-1])+ABS(y[i]-y[i-1])) )%2==1 ){
            printf("No\n");
            return 0;
        }
    }
    printf("Yes\n");
    return 0;
}


Measured memory_bytes: 2560
x = int(input())
for i in range(1,x+1):
    if i % 3 == 0:
        print(' ' + str(i), end = "")
    else:
        n = i
        while(n):
            if n % 10 == 3:
                print(' ' + str(i), end = "")
                break
            n = n // 10
print()


Measured memory_bytes: 5868
#include<stdio.h>
int main()
{
    int a,b,d,div;

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

    if(a>b)
    {
        d = (a-b);
        div = d/2;

        if(d%2==0) printf("%d\n",div+b);

        else printf("IMPOSSIBLE\n");
    }

    else if(a<b)
        {
            d = (b-a);
            div = d/2;

            if(d%2==0) printf("%d\n",div+a);

            else printf("IMPOSSIBLE\n");
        }
        
    return 0;
}


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

using namespace std;

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

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;

int gcd(int a, int b) {
    if (b == 0) {
        return a;
    } else {
        return gcd(b, a % b);
    }
}

int lcm(int a, int b) {
    return a * b / gcd(a, b);
}

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int div2(int x) {
  int cnt = 0;
  while (x % 2 == 0) {
    x /= 2;
    cnt++;
  }
  return cnt;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;  cin >> n;
    int times = 0;
    int ans = 1;
    FOR(i, 1, n + 1) {
      if (times < div2(i)) {
        times = div2(i);
        ans = i;
      }
    }
    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 int n,a,check,num;
  
  cin >> n;
  
  num = 1;
  check = 0;
  for(int i = 0;i<n;++i){
    cin >> a;
    
        
    if(a == num){
      ++num;
    }
    else{
      ++check;
    }
  }
  if(check == n) check = -1;
  cout << check << endl;
}

  

Measured memory_bytes: 256
/*
        ####   ####
     ###    ###    ###
   ###    Bravery    ###
  ###  Determination  ###
   ##  Perseverance   ##
    ##   Integrity   ##
     ##  Patience   ##
      ## Kindness  ##
        ##Justice##
         ##     ##
           ## ##
             #
*/
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
typedef long long ll;
using namespace std;
string str;
int n,m;
int main(){
	cin>>str;
	for (int i=0;i<str.size();i++){
		if (str[i]=='A' || str[i]=='C' || str[i]=='G' || str[i]=='T'){
			n++;
		}else{
			m=max(m,n);
			n=0;
		}
	}
	m=max(m,n);
	cout<<m<<endl;
	return 0;
}

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

const int MAX = 1e+5;
int N;
int A[MAX+1];

int main() {
  // 入力
  cin >> N;
  for (int i=0; i<N; i++) cin >> A[i];
  // 貪欲法で単調増加か単調減少がなるべく長くなるように配列を分割していく
  bool increase;
  int cnt = 0;
  while (A[cnt] == A[cnt+1]) cnt++;
  increase = (A[cnt] < A[cnt+1]) ? true : false;
  int ans = 0;
  for (int i=cnt; i<N-1; i++) {
    while (A[i] == A[i+1]) i++;
    increase = (A[i] < A[i+1]) ? true : false;
    if (increase) {
      while (A[i] <= A[i+1]) i++;
    } else {
      while (A[i] >= A[i+1]) i++;
    }
    ans++;
  }
  if (increase && A[N-2] > A[N-1]) ans++;
  if (!increase && A[N-2] < A[N-1]) ans++;
  // 解答
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
import math
N = int(input())
A = list(map(int, input().split()))

maxA = max(A) + 1

C = [0] * maxA

g = 0

for a in A:
    C[a] += 1
    g = math.gcd(g, a)

pairwise = True

is_prime = [True] * maxA

for i in range(2, maxA):
    if is_prime[i]:
        cnt = 0
        for j in range(i, maxA, i):
            cnt += C[j]
            is_prime[j] = False

        if cnt > 1:
            pairwise = False

if pairwise:
    print("pairwise coprime")
    exit()

if g == 1:
    print("setwise coprime")

else:
    print("not coprime")

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

int int_len(int n) {
  int s=0;
  while(n!=0) s++, n/=10;
  return s;
}

int int_sum(int n) {
  int m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(int i=s-1;i>=0;i--) m+=n/((int)pow(10,i))-(n/((int)pow(10,i+1)))*10;
  return m;
}

int fac(int n){
  int m=1;
  while(n>=1) m*=n,n--;
  return m;
}

int vec_sum(vector<int> v){
  int n=0;
  for(int i=0;i<v.size();i++) n+=v[i];
  return n;
}
///////////////////////////
int main() {
  int n,m,count=0;
  cin>>n>>m;
  vector<string> a(n),b(m);
  bool flag=false;
  rep(i,n) cin>>a[i];
  rep(i,m) cin>>b[i];
  for(int i=0;i<n-m+1;i++){
    for(int j=0;j<n-m+1;j++){
      
      
      for(int k=0;k<m;k++){
        flag=true;
        for(int l=0;l<m;l++){
          if(a[i+k][j+l]!=b[k][l]) flag=false;
        }
        if(!flag) break;
      }
      
      if(flag){
        cout<<"Yes"<<endl;
        return 0;
      }
      
      
      
    }
  }
  cout<<"No"<<endl;
  
  
}
///////////////////////////

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

int main() {
    int k, x;
    cin >> k >> x;
    auto left = x - (k - 1);
    auto right = x + (k - 1);
    for (int i = left; i <= right; i++)
        printf("%d%c", i, (i == right ? '\n' : ' '));
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<stdio.h>
#include <string>
#include <complex>
#include <functional>
#include <map>
#include <queue>
using namespace std;
using ll = long long;
//typedef pair<string,string> P;
//double dat[100][100];
//int dp[6][1010];//動的計画法
//int prime[100001];
//char str[1010][1010];
//vector<pair<ll,ll>> pc;
//int ABS(int a){return max(a,-a);}
//int a[100001];
int main(){
    int n,m,c;
    cin>>n>>m>>c;
    int b[m];
    int cnt=0;
    for(int i=0;i<m;i++){
        cin>>b[i];
    }
    for(int i=0;i<n;i++){
      int ans=c;
        for(int j=0;j<m;j++){
            int a;
            cin>>a;
            ans+=a*b[j];
        }
        if(ans>0) cnt++;
    }
    cout<<cnt;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <random>
#include <tuple>
#include <iomanip>
#include <cstring>

using namespace std;

typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define revrep(i, n) for(ll i = (n-1); i >= 0; i--)
#define pb push_back
#define f first
#define s second
const ll INFL = 1LL << 60;//10^18 = 2^60
const int INF = 1 << 30;//10^9
ll MOD = 1000000007;
//ll MOD  = 998244353;
vector<ll> dy = {0, 0, 1, -1, 1, 1, -1, -1, 0};
vector<ll> dx = {1, -1, 0, 0, 1, -1, 1, -1, 0};

ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}

ll pow_long(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x;
    k /= 2;
  }
  return res;
}
ll pow_mod(ll x, ll k){
  x %= MOD; x += MOD; x %= MOD;
  ll res = 1;
  while(k > 0){
    if(k % 2){
      res *= x; res %= MOD;
    }
    x *= x; x %= MOD;
    k /= 2;
  }
  return res;
}

ll inverse(ll x){return pow_mod(x, MOD - 2);};

ll gcd(ll a, ll b){
    if(b == 0) return a;
    return gcd(b, a % b);
}

ll lcm(ll x, ll y){return x / gcd(x, y) * y;};

ll kai_mod(ll x){
  if(x == 0) return 1;
  return x * kai_mod(x-1) % MOD;
}

/*
//コンビネーション
const int MAXcomb = 200010;
ll fac[MAXcomb], finv[MAXcomb], inv[MAXcomb];
//facはn!,finvは1/n!
//invは逆元
void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAXcomb; i++){
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
ll comb(int n, int k){
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * finv[k] % MOD * finv[n-k] % MOD;
}
*/

int main(){
  vector<ll> cnt(4, 0);
  rep(i, 6){
    int a;
    cin >> a;
    cnt[--a]++;
  }
  rep(i, 4){
    if(cnt[i] >= 3){
      cout << "NO" << endl;
      return 0;
    }
  }
  rep(i, 4){
    if(cnt[i] == 0){
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;

}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<string>
#include<cstring>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<bitset>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;

#define PI 3.141592653589793238462643383279
#define mod 1000000007LL
#define rep(i, n) for(i = 0;i < n;++i)
#define rep1(i, n) for(i = 1;i < n;++i)
#define per(i, n) for(i = n - 1;i > -1;--i)
#define int(x) int x; scanf("%d",&x)
#define int2(x, y) int x, y; scanf("%d%d",&x, &y)
#define int3(x, y, z) int x, y, z; scanf("%d%d%d",&x, &y, &z)
#define int4(v, x, y, z) int v, x, y, z; scanf("%d%d%d%d", &v, &x, &y, &z)
#define int5(v, w, x, y, z) int v, w, x, y, z; scanf("%d%d%d%d%d", &v, &w, &x, &y, &z)
#define ll2(x, y) ll x, y; cin >> x >> y;
#define scn(n, a) rep(i, n)cin >> a[i]
#define sc2n(n, a, b) rep(i, n)cin >> a[i] >> b[i]
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define endl "\n"
#define kabe puts("---------------------------")
#define kara puts("")
#define debug(x) cout << " --- " << (x) << "\n"
#define debug2(x, y) cout << " --- " << (x) << " " << (y) << "\n"
#define debug3(x, y, z) cout << " --- " << (x) << " " << (y) << " " << (z) << "\n"
#define X first
#define Y second
#define eps 0.0001
#define prid(x) printf("%.15lf\n", x)

int f[9][9];
int dh[9] = {0, 0, 0, 1, 1, 1, 2, 2, 2};
int dw[9] = {0, 1, 2, 0, 1, 2, 0, 1, 2};

signed main(void){
  int i, j, k, l, m;
  int(n);
  for(int testcase = 0;testcase < n;testcase++){
    if(testcase != 0)puts("");
    rep(i, 9)rep(j, 9)scanf("%d", &f[i][j]);
    rep(i, 9){
      rep(j, 9){
        bool is = true;
        rep(k, 9){
          if(i != k)if(f[i][j] == f[k][j])is = false;
          if(j != k)if(f[i][j] == f[i][k])is = false;
          if(i % 3 != dh[k] && j % 3 != dw[k])
          if(f[i][j] == f[i / 3 * 3 + dh[k]][j / 3 * 3 + dw[k]])is = false;
        }
        if(is)printf(" %d", f[i][j]);
        else printf("*%d", f[i][j]);
      }
      puts("");
    }


//*/

//*/ break;
  }
  return 0;
}

Measured memory_bytes: 3112