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

using namespace std;

typedef long long ll;

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

    int N;
    cin >> N;

    for (int i = 0; i < N; i++) {
        for (int  j = 0; j < N; j++) {
            if (4 * i + 7 * j == N) {
                cout << "Yes" << endl;
                exit(0);
            }
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rp(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

ll p[200050];
void solve(){
    ll n,k;
    cin >> n >> k;
    rp(i,n) cin >> p[i];
    priority_queue<PLL> que1;
    p_queue(PLL) que2;
    queue<PLL> okque1,okque2;
    rp(i,n){
        if(i==0) {que1.push(mp(p[0],0)); continue;}
        while(que1.top().first>p[i]&&!que1.empty()){
            PLL pl=que1.top(); que1.pop();
            if(pl.second<=i-k) okque1.push(pl);
        }
        que1.push(mp(p[i],i));
    }
    for(ll i=n-1; i>=0; i--){
        if(i==n-1) {que2.push(mp(p[n-1],n-1)); continue;}
        while(que2.top().first<p[i]&&!que2.empty()){
            PLL pl=que2.top(); que2.pop();
            if(pl.second>=i+k+1) okque2.push(pl);
        }
        que2.push(mp(p[i],i));
    }
    set<ll> pos;
    while(!que1.empty()){
        pos.insert(que1.top().second+k);
        que1.pop();
    }
    while(!okque1.empty()){
        pos.insert(okque1.front().second+k);
        okque1.pop();
    }
    ll ans=n-k+1;
    while(!que2.empty()){
        ll po=que2.top().second; que2.pop();
        auto it=pos.find(po);
        if(it!=pos.end()) ans--;
    }
    while(!okque2.empty()){
        ll po=okque2.front().second; okque2.pop();
        auto it=pos.find(po);
        if(it!=pos.end()) ans--;
    }
    ll streak=1;
    bool ok=false;
    rp(i,n-1){
        if(p[i]<p[i+1]) streak++;
        else streak=1;
        if(streak==k){
            if(ok) ans--;
            ok=true;
        }
    }
    print(ans);
    return;
}
int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    solve();
    return 0;
}

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

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

using ll = long long;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int INF = 1<<30;
const ll mod = 1000000007LL;

ll pow(ll a, ll n) {
	ll ret = 1LL;
	for (; n > 0LL; n >>= 1LL, a = a * a) {
		if (n % 2LL == 1LL) {
			ret = ret * a;
		}
	}
	return ret;
}

int main() {
  ll N,K;
  cin>>N>>K;
  vector<ll> v(N);
  for(ll i = 0; i < N; i++) cin>>v[i];
  ll total = 0;
  for(auto x:v) total+=x;
  map<ll,ll> m;
  ll s = total;
  for(ll i = 2; i*i<=total; i++){
    while(s%i==0){
      s/=i;
      m[i]++;
    }
  }
  if(s!=1) m[s]++;
  vector<ll> ya;
  ya.push_back(1LL);
  for(auto x:m){
    ll s = ya.size();
    for(ll i = 0; i < s; i++){
      for(ll j = 1; j <= x.second;j++){
        ya.push_back(ya[i]*pow(x.first,j));
      }
    }
  }
  sort(ya.begin(),ya.end());
  reverse(ya.begin(),ya.end());
  for(ll i = 0; i < (ll)ya.size(); i++){
    vector<ll> w(N);
    for(ll j = 0; j < N; j++) w[j]=v[j]%ya[i];
    sort(w.begin(),w.end());
    reverse(w.begin(),w.end());
    ll T = 0LL;
    for(auto x:w) T+=x;
    T/=ya[i];
    ll cnt = 0;
    for(ll j = 0; j < T; j++){
      cnt+=ya[i]-w[j];
    }
    if(cnt<=K){
      cout<<ya[i]<<endl;
      break;
    }
  }
}

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

using namespace std; 
int main()
{
string s;
cin>>s;

 for(int i=0;i<s.length();i++){
 	
 	if(s[i]==','){
 		cout<<" ";
	 }
	 else
	 cout<<s[i];
 }
}

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

using namespace std;

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

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

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

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

bool cmp(pair <string, pii> a, pair <string, pii> b)
{
    if(a.ft == b.ft) return a.sd > b.sd;
    return a.ft < b.ft;
}
void solve(){
    ll n;
    vector<pair <string, pii>> v;
    cin >> n;
    rep(i, n)
    {
        string s; ll x;
        cin >> s >> x;
        v.pb({s,{x, i}});
    }
    sort(all(v), cmp);
    for(auto x: v) cout <<x.sd.sd+1 << endl;

}
main(){
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/
    fast();
    ll t = 1; //cin >> t;
    while(t--){
        solve();
    }
}


Measured memory_bytes: 256
// https://onlinejudge.u-aizu.ac.jp/status/users/uzi7215/submissions/1/ALDS1_10_C/judge/3551530/Python3
#include <iostream>
#include <vector>

int main(){
  int q;
  std::cin >> q;
  std::vector<std::string> x_list, y_list;
  for( int i=0; i<q; i++ ){
    std::string input;
    std::cin >> input;
    x_list.push_back( input );
    std::cin >> input;
    y_list.push_back( input );
  }

  for( int k=0; k<q; k++ ){
    std::string x = x_list[k];
    int m = x.size() + 1;
    std::string y = y_list[k];
    int n = y.size() + 1;
    std::vector< std::vector<int> > c(m, std::vector<int>(n, 0));

	int i, j;
    for( i=1; i<m; i++ ){
      for( j=1; j<n; j++ ){
      	if( i==0 or j==0){
      		c[i][j] = 0;
		}else if( x[i-1] == y[j-1] ){
          c[i][j] = c[i-1][j-1] + 1;
        }else{
          c[i][j] = std::max( c[i-1][j], c[i][j-1] );
        } 
      }
    }
    std::cout << c[m-1][n-1] << std::endl;
  }
}



Measured memory_bytes: 6876
n,m,x= map(int,input().split())
texts = [list(map(int,input().split())) for i in range(n)]
judge = False
min_ex = 10**7

for bit in range(2**n):
    understand = [0]*m
    expense = 0
    for i in range(n):
        if bit>>i & 1:
            expense += texts[i][0]
            for j in range(m):
                understand[j] += texts[i][j+1]
    if min(understand) >= x:
        judge = True
        min_ex = min(expense, min_ex)

if judge:
    print(min_ex)
else:
    print(-1)



Measured memory_bytes: 9240
#include<iostream>
#include<string>

using namespace std;
 
int main(){
  string s;
  cin>>s;
  int size = s.length();
  if((s[size-1]==s[size-2] && s[size-2]==s[size-3]) || (s[size-2]==s[size-3] && s[size-3]==s[size-4]))
  {
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 256
S = input()
n = len(S)
l = [0 if S[i] == 'B' else 1 for i in range(n)]
cnt = 0
lenB = 1
for i in range(n-1):
    if l[i] == 0 and l[i+1] == 0: lenB += 1
    if l[i] == 0 and l[i+1] == 1:
        l[i+1] = 0
        cnt += lenB
print(cnt)

Measured memory_bytes: 82668
#include<algorithm>     //sort,二分探索,など
#include<bitset>        //固定長bit集合
#include<cmath>         //pow,logなど
#include<complex>       //複素数
#include<deque>         //両端アクセスのキュー
#include<fstream>       //ファイルストリーム（標準入力変更用）
#include<functional>    //sortのgreater
#include<iomanip>       //setprecision(浮動小数点の出力の誤差)
#include<iostream>      //入出力
#include<iterator>      //集合演算(積集合,和集合,差集合など)
#include<map>           //map(辞書)
#include<numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include<queue>         //キュー
#include<set>           //集合
#include<stack>         //スタック
#include<string>        //文字列
#include<unordered_map> //イテレータあるけど順序保持しないmap
#include<unordered_set> //イテレータあるけど順序保持しないset
#include<utility>       //pair
#include<vector>        //可変長配列

//名前
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef map<string, int> msi;
typedef map<string, ll> msll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pllll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef vector<vector<string>> vvs;
typedef vector<vector<bool>> vvb;

//定数
const ll MOD = 1000000007;
const ll INF = 1000000000000000000;

//マクロ
#define rep(i,n) for(int i=0;i<n;i++)
#define reps(i,s,e) for(int i=s;i<e;i++)
#define repse(i,s,e) for(int i=s;i<=e;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define in(x1) cin >> x1
#define in2(x1, x2) cin >> x1 >> x2
#define in3(x1, x2, x3) cin >> x1 >> x2 >> x3
#define inN(x, N) rep(i, N) in(x[i])
#define outl(x) cout << x << endl
#define out2l(x, y) cout << x << " " << y << endl 

//よく使う関数
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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

    //標準入力をファイルに変更
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());


    int N, A;
    in2(N, A);

    int count = N / A;
    if (N % A != 0) count++;

    outl(count);
    return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
 
int main(void){
    int n;
    cin >> n;

    vector<int> h(n);

    for(int i = 0;i < n;i++){
        cin >> h[i];
    }
    int ans = 0;
    for(int i = 0;i < n-1;i++){
        int count = 0;
        while(h[i] >= h[i+1] && i < n-1){
            count++;
            i++;
        }

        ans = max(ans,count);

    }

    cout << ans << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using std::cout;
using std::cin;
using std::endl;

int main()
{
    int r, c;

    cin>>r>>c;

    int mat[r][c], rsum[c], csum[r];
    for (int i = 0; i < c+1; i++)
        rsum[i]=0;
    for (int i = 0; i < r; i++)
        csum[i]=0;
    
    for (int i = 0; i < r; i++)
    {
        for (int j = 0; j < c; j++)
            cin>>mat[i][j];
    }

    for (int i = 0; i < r; i++)
    {
        for (int j = 0; j < c; j++)
        {
            cout<<mat[i][j]<<" ";
            csum[i]+=mat[i][j];
            rsum[j]+=mat[i][j];
        }
        rsum[c]+=csum[i];
        cout<<csum[i]<<endl;

    }
    cout<<rsum[0]<<std::flush;
    for (int i = 1; i < c+1; i++)
        cout<<" "<<rsum[i];
    
    cout<<endl;
    return 0;
}


Measured memory_bytes: 3128
#![allow(non_snake_case)]

use std::io::{stdin, Read};
use std::str::FromStr;
fn read_option<T: FromStr>() -> Option<T> {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok()
}
fn read<T: FromStr>() -> T {
    let opt = read_option();
    opt.expect("failed to parse token")
}

fn main() {
    let H: usize = read();
    let W: usize = read();
    let M: usize = read();
    let mut rows: Vec<usize> = vec![0; H];
    let mut columns: Vec<usize> = vec![0; W];
    let mut subjects = vec![];
    for _ in 0..M {
        let row: usize = read();
        rows[row - 1] += 1;
        let column: usize = read();
        columns[column - 1] += 1;
        subjects.push((row - 1, column - 1));
    }
    let mut rows: Vec<_> = rows.into_iter().enumerate().collect();
    let mut columns: Vec<_> = columns.into_iter().enumerate().collect();
    rows.sort_by_key(|v| v.1);
    columns.sort_by_key(|v| v.1);
    use std::collections::HashSet;
    let mut max_rows = HashSet::new();
    let mut max_columns = HashSet::new();
    for &(i, v) in &rows {
        if v == rows[rows.len() - 1].1 {
            max_rows.insert(i);
        }
    }
    for &(i, v) in &columns {
        if v == columns[columns.len() - 1].1 {
            max_columns.insert(i);
        }
    }
    let mut count = 0;
    for (row, column) in subjects {
        if !(max_rows.contains(&row) && max_columns.contains(&column)) {
            continue;
        }
        count += 1;
    }
    if max_rows.len() * max_columns.len() == count {
        println!(
            "{}",
            rows[rows.len() - 1].1 + columns[columns.len() - 1].1 - 1
        );
    } else {
        println!("{}", rows[rows.len() - 1].1 + columns[columns.len() - 1].1);
    }
}


Measured memory_bytes: 29856
#[allow(unused_imports)]
use std::collections::VecDeque;
#[allow(unused_imports)]
use std::cmp;
#[allow(unused_imports)]
use std::collections::HashMap;

#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        #[allow(unused_variables)]
        #[allow(unused_mut)]
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
 
    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
 
    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };
 
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
 
    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };
 
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };
 
    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("parse error")
    };
}

fn main() {
    input!{
        n: f64
    }
    let mut p = 100.0;
    let mut count = 0;
    while p < n {
        count+=1;
        p *= 1.01;
        p = p as i64 as f64;
    }
    println!("{}", count);
}


Measured memory_bytes: 2168
#include <stdio.h>

int main(){

  int n,s,ohjk,a[25],i,j;
  while(1){
    scanf("%d",&n);
    if(n==0)break;
    for(i=0;i<25;i++)a[i]=0;
    for(i=0;i<n;i++){
      scanf("%d",&s);
      a[i]=s;
    }
    ohjk=32;
    j=0;
    while(1){
      ohjk -= (ohjk-1)%5;
      printf("%d\n",ohjk);
      if(ohjk==1)break;
      ohjk -= a[j];
      printf("%d\n",ohjk);
      if(j<n-1)j++;
      else j=0;
    }
    printf("0\n");
  }
  return 0;
}

Measured memory_bytes: 608
/*  -*- coding: utf-8 -*-
 *
 * 2881.cc: Change of the Era Name
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

/* typedef */

/* global variables */

char sd[16];

/* subroutines */

/* main */

int main() {
  while (scanf("%s", sd) == 1 && sd[0] != '#') {
    int y, m, d;
    scanf("%d%d%d", &y, &m, &d);

    if (y > 31 || (y == 31 && m >= 5))
      printf("? %d %d %d\n", y - 31 + 1, m, d);
    else
      printf("HEISEI %d %d %d\n", y, m, d);
  }
  return 0;
}



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

int main(void){
   string s1,s2,s3;
   cin>>s1>>s2>>s3;
   char s=toupper(s1[0]);
   char t=toupper(s2[0]);
   char u=toupper(s3[0]);
   cout<<s<<t<<u<<endl;
   return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<string>
#include<cstring>
#include<bitset>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<numeric>
#include<set>
using namespace std;

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

#define rep(i,x) for(int i=0;i<x;i++)
#define re(i,x,y) for(int i=x;i<y;i++)

long long INF=1e9;
const long long mod=2019;
#define ll long long

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    double n,k; cin>>n>>k;
    double ans=0;
    for(double i=1;i<=n;i++){
        int tmp=i;
        double prb=1;
        while(tmp<k){
            tmp*=2;
            prb/=2;
        }
        ans+=prb;
    }
    ans/=n;
    printf("%.15f\n",ans);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void) {
int hello[101];
for(int i = 0; i < 101; ++i) {
hello[i] = 0;
}
int a, b, c;
cin >> a >> b >> c;
hello[a] += 1;
hello[b] += 1;
hello[c] += 1;
int count = 0;
for(int i = 0; i < 101; ++i){
if(hello[i]) ++count;
}
cout << count << endl;
return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int const NMAX = 100;
int v[1 + NMAX];

int main() {

  int n;
  cin >> n;
  v[0] = 1;
  for(int i = 1;i <= n;i++){
    if(i - 4 >= 0){
      v[i] += v[i-4];
    }
    if(i - 7 >= 0){
      v[i] += v[i-7];
    }
  }
  if(v[n] >= 1){
    cout << "Yes";
  }else{
    cout << "No";
  }
  return 0;
}


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


int main() {

	int N, Alice, Bob;
	int a[110];
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> a[i];
	}

	sort(a,a + N,greater<int>());

	Alice = 0; Bob = 0;

	for (int i = 0; i < N; i++) {
		if (i %2 == 0) Alice += a[i];
		if (i %2 != 0) Bob += a[i];
	}

	cout << Alice - Bob;

}

Measured memory_bytes: 256
from collections import deque
k = int(input())
q = deque([1, 2, 3, 4, 5, 6, 7, 8, 9])
for i in range(k):
    x = q.popleft()
    a = 10*x+(x % 10)
    if x % 10 != 0:
        q.append(a-1)
    q.append(a)
    if x % 10 != 9:
        q.append(a+1)

print(x)


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

using namespace std;

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

    int N,M;cin>>N>>M;
    const long MOD = 1e9+7;
    auto mod = [&](long x) {
        return x % MOD;
    };
    vector<long> dp(3, 0);
    dp[0] = 1;
    int a; cin>>a;
    for (int i = 1; i <= N; i++) {
        if (i == a) {
            dp[i%3] = 0;
            if (M) {
                cin>>a;
                M--;
            }
        } else {
            dp[i%3] = mod(dp[(i+2)%3] + dp[(i+1)%3]);
        }
    }
    auto ans = dp[N%3];
    cout << ans << endl;

    return 0;
}



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

bool cards[4][13];
string marks[4]={"S","H","C","D"};

int main(){
    int n;
    cin >> n;
    for(int i=0;i<n;i++){
        char ch;
        int x;
        cin >>ch>>x;
        int index;
        if(ch=='S')index=0;
        else if(ch=='H')index=1;
        else if(ch=='C')index=2;
        else index=3;
        cards[index][x-1] = 1;
    }
    
    for(int i=0;i<4;i++){
        for(int j=0;j<13;j++){
            if(cards[i][j]==0){
                cout<< marks[i] <<" "<<j+1<<endl;
            }
        }
    }

return 0;
}


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

int main(){
    int k;
    string s;
    cin >> k >> s;
    int a=s.size();
    if (a<=k){
        cout << s << endl;
    }
    else{
        for (int i=0; i<k; i++){
            cout << s.at(i) ;
        }
        cout << "..." << endl;
    }
    return 0;
}

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

int main() {
  int a[3];
  for(int i=0;i<3;i++){
    cin>>a[i];
  }
  sort(a,a+3);
  int res=a[2]-a[1];
  if((a[2]-(a[0]+res))%2==0) res+=(a[2]-(a[0]+res))/2;
  else res+=1+(a[2]+1-(a[0]+res))/2;
  cout<<res<<endl;
  return 0;
}


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

int main()
{
    int red, green, blue, k;

    cin >> red >> green >> blue >> k;

    int count1 = 0;
    
    while(red>=green)
    {
        green *= 2;
        count1++;
    }
    
    while(green>=blue)
    {
        blue *= 2;
        count1++;
    }
    
    if(k>=count1)
    {
        cout << "Yes";
    }
    
    else
    {
        cout << "No";
    }
    
    return 0;

}


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

#define lli long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)
#define MOD 1000000007

bool comp(int a, int b){
    return (a<b);
}

int main(){
    int n=3;
    int sum = 0;
    vector<int> a(n);
    REP(i,0,n) cin >> a[i];
    sort(a.begin(), a.end());
    sum=(a[1]-a[0])+(a[2]-a[1]);
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<queue>
#include<cstring>
#include<algorithm>
#define pii pair<int,int>
#define mp make_pair
using namespace std;
int n,m,k,cx,cy,ans=1e9;
char s[805][805];
int d[805][805];
const int dx[]={0,1,-1,0},dy[]={1,0,0,-1};
void bfs()
{
	queue<pii> q;
	q.push(mp(cx,cy));d[cx][cy]=0;
	while(!q.empty())
	{
		int x=q.front().first,y=q.front().second;
		q.pop();
		for(int i=0;i<4;i++)
		{
			int nx=x+dx[i],ny=y+dy[i];
			if(d[nx][ny]<=d[x][y]+1||s[nx][ny]=='#')continue;
			d[nx][ny]=d[x][y]+1;
		    q.push(mp(nx,ny));
	    }
	}
}
int main()
{
	scanf("%d%d%d",&n,&m,&k);
	for(int i=1;i<=n;i++)
	{
		scanf("%s",s[i]+1);
		for(int j=1;j<=m;j++)
		{if(s[i][j]=='S')cx=i,cy=j,s[i][j]='.';d[i][j]=1e9;} 
	}
	bfs();
	for(int i=1;i<=n;i++)
	for(int j=1;j<=m;j++)
	if(d[i][j]<=k)
	ans=min(ans,1+(min(min(i-1,n-i),min(j-1,m-j))+k-1)/k);
	printf("%d\n",ans);
	return 0;
}


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

using Edge = pair<int,int>;
using Graph = vector<vector<Edge> >;

// 入力
int N;
Graph G;

// res は答え
vector<int> res;

// v を c に塗る。p は v の親
void dfs(int v, int p, int c) {
    res[v] = c;
    for (auto e : G[v]) {
        if (e.first == p) continue;
        if (e.second & 1) dfs(e.first, v, 1-c);
        else dfs(e.first, v, c);
    }
}

int main() {
    cin >> N;
    G.assign(N, vector<Edge>());
    for (int i = 0; i < N-1; ++i) {
        int u, v, w; cin >> u >> v >> w;
        --u, --v;
        G[u].push_back(Edge(v, w));
        G[v].push_back(Edge(u, w));
    }
    res.assign(N, 0);
    dfs(0, -1, 1);
    for (auto v : res) cout << v << endl;
}

Measured memory_bytes: 8960
#include <stdio.h>
int aNum[1000000] = {};
int main() {
	int s, a, befa, cou = 1;
	scanf("%d", &s);
	befa = s;
	aNum[befa]++;
	while (1) {
		if (befa % 2 == 0) {
			a = befa / 2;
		}
		else {
			a = 3 * befa + 1;
		}
		aNum[a]++;
		cou++;
		if (aNum[a] == 2) {
			break;
		}
		befa = a;
	}
	printf("%d", cou);
	return 0;
}

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

typedef long long ll;

using namespace std;

int main(){
	//freopen("input.in","r",stdin);
	//freopen("output.in","w",stdout);
	ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int i,j,k;
    string s;
    cin>>s;
    int ans(0);
    for(auto ch:s)ans+=ch-'0'; 
    if(ans%9)cout<<"No\n";
	else cout<<"Yes\n";
	
	
	







	return 0;
}

Measured memory_bytes: 3792
fn main() {
    let mut sc = Scanner::new();
    let n = sc.usize_read();
    let a: Vec<usize> = sc.read_vec(n);
    let mut count = vec![0; n];
    for &a in &a {
        count[a] += 1;
    }
    let max: usize = a.iter().map(|&i| i).max().unwrap();
    let min: usize = a.iter().map(|&i| i).min().unwrap();
    if max - min > 1 {
        println!("No");
    } else if max == min {
        if max == n - 1 || max * 2 <= n {
            println!("Yes");
        } else {
            println!("No");
        }
    } else {
        let unique = count[min];
        if max > unique && (max - unique) * 2 + unique <= n {
            println!("Yes");
        } else {
            println!("No");
        }
    }
}

struct Scanner {
    ptr: usize,
    length: usize,
    buf: Vec<u8>,
    small_cache: Vec<u8>,
}

#[allow(dead_code)]
impl Scanner {
    fn new() -> Scanner {
        Scanner {
            ptr: 0,
            length: 0,
            buf: vec![0; 1024],
            small_cache: vec![0; 1024],
        }
    }

    fn load(&mut self) {
        use std::io::Read;
        let mut s = std::io::stdin();
        self.length = s.read(&mut self.buf).unwrap();
    }

    fn byte(&mut self) -> u8 {
        if self.ptr >= self.length {
            self.ptr = 0;
            self.load();
            if self.length == 0 {
                self.buf[0] = b'\n';
                self.length = 1;
            }
        }

        self.ptr += 1;
        return self.buf[self.ptr - 1];
    }

    fn is_space(b: u8) -> bool {
        b == b'\n' || b == b'\r' || b == b'\t' || b == b' '
    }

    fn read_vec<T>(&mut self, n: usize) -> Vec<T>
    where
        T: std::str::FromStr,
        T::Err: std::fmt::Debug,
    {
        (0..n).map(|_| self.read()).collect()
    }

    fn usize_read(&mut self) -> usize {
        self.read()
    }

    fn read<T>(&mut self) -> T
    where
        T: std::str::FromStr,
        T::Err: std::fmt::Debug,
    {
        let mut b = self.byte();
        while Scanner::is_space(b) {
            b = self.byte();
        }

        for pos in 0..self.small_cache.len() {
            self.small_cache[pos] = b;
            b = self.byte();
            if Scanner::is_space(b) {
                return String::from_utf8_lossy(&self.small_cache[0..(pos + 1)])
                    .parse()
                    .unwrap();
            }
        }

        let mut v = self.small_cache.clone();
        while !Scanner::is_space(b) {
            v.push(b);
            b = self.byte();
        }
        return String::from_utf8_lossy(&v).parse().unwrap();
    }
}


Measured memory_bytes: 6396
#include<iostream>
    using namespace std;
    int main(){
      int N;
      cin>>N;
      if(N>=195)cout<<5<<endl;
      else if(N>=189)cout<<4<<endl;
      else if(N>=165)cout<<3<<endl;
      else if(N>=135)cout<<2<<endl;
      else if(N>=105)cout<<1<<endl;
      else cout<<0<<endl;
      return 0;
      
    }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
const int maxV = 90010;
const int maxN = 1e5+10;
const int inf = 0x3f3f3f3f;
const ll MOD = 1e9+7;
const ll INF = 1000000000000000010LL;
#define X first
#define Y second


int n;
int a[maxN];
int b[maxN];
int get(int x)
{
	if(x == -1)
	{
		return 3;
	}
	else
		return b[x];
}
int main() {
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
	}
	ll ans = 1;
	for(int i=1;i<=n;i++)
	{
		int x = a[i];
		int c1 = get(x-1);
		int c2 = get(x);
		ans = (ans * (c1-c2))%MOD;
		b[x]++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include<string>
#include<string.h>
#include<map>
#include<set>
#include<vector>
#include<stdio.h>
#include<math.h>
#include<iostream>
#include<algorithm>
#include<queue>


using namespace std;


int main()
{
    string s;
    cin>>s;
    int ans=700;
    for(int i=0;i<s.size();i++)
    if(s[i]=='o')
    ans=ans+100;
    cout<<ans;

    return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int t[52][52] = {};
  string s[52];
  int h, w;
  int i, j, k;
  int ns[8] = {-1, -1, -1, 0, 0, 1, 1, 1};
  int ew[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
  cin >> h >> w;
  for(i = 1; i <= h; i++){
    cin >> s[i];
    for(j = 1; j <= w; j++){
      if(s[i][j-1] == '#'){
        for(k = 0; k < 8; k++)
          t[i + ns[k]][j + ew[k]] += 1;
      }
    }
  }
  for(i = 1; i <= h; i++){
    for(j = 1; j <= w; j++){
      if(s[i][j-1] == '#')
        putchar('#');
      else
        putchar(t[i][j] + '0');
    }
    putchar('\n');
  }
  
  return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-

N, T = map(int, input().split())
tn = list(map(int, input().split()))

estime = T
for i in range(1,N):
    if tn[i] - tn[i-1] > T:
        estime += T
    else:
        estime += tn[i] - tn[i-1]

print(estime)


Measured memory_bytes: 26708
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define rep(i, m, n) for (lli i = m; i < (n); i++)
#define repe(i, m, n) for (lli i = m; i <= (n); i++)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((lli)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define _GLIBCXX_DEBUG
const lli INF = 2147483647;
const lli MINF = -2147483648;
const lli LINF = 9223372036854775807;
const lli MOD = 1000000007; //10^9+7
const double PI = acos(-1);
#define SORT(n) sort(n.begin(), n.end())
#define SORTR(n) sort(n.begin(), n.end(), greater<int>())
#define REV(n) reverse(n.begin(), n.end())
#define pb push_back
#define eb emplace_back
#define mp make_pair
#pragma GCC optimize("Ofast")
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vlli = vector<lli>;
using vvli = vector<vlli>;
using vs = vector<string>;
using vvs = vector<vs>;
using vb = vector<bool>;
using vvb = vector<vb>;
using ll = long long;
// vector入力
template <typename T>
istream &operator>>(istream &is, vector<T> &vec)
{
  for (T &x : vec)
    is >> x;
  return is;
}
// vector出力
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec)
{
  // os << '{';
  for (int i = 0; i < vec.size(); i++)
  {
    os << vec[i] << (i + 1 == vec.size() ? "" : "");
  }
  // os << '}';
  return os;
}
// aよりもbが大きいならばaをbで更新する(更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T &b)
{
  if (a < b)
  {
    a = b; // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する(更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T &b)
{
  if (a > b)
  {
    a = b; // aをbで更新
    return true;
  }
  return false;
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli a, b, c, h, n, w, ans = 0, count = 0;
  string s, t;
  vector<pair<string, pair<lli, lli>>> pr;
  cin >> n;
  vlli d(n), e;
  rep(i, 0, n)
  {
    cin >> d[i];
    e.pb(d[i]);
    ans += d[i];
  }
  SORT(e);
  rep(i, 0, n)
  {
    if (ans % 10 != 0)
    {
      cout << ans << endl;
      return 0;
    }
    else
    {
      if (e[i] % 10 != 0)
      {
        ans -= e[i];
      }
      else
      {
        continue;
      }
    }
  }
  cout << 0 << endl;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define LL long long
const int Maxn=200010;
const int inf=2147483647;
int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
	return x*f;
}
int n,m;
struct Node
{
	int tag,v,lc,rc,l,r;
};
struct Seg
{
	Node tr[Maxn<<1];
	int tot;
	void init(){tot=0;}
	void build(int l,int r)
	{
		int x=++tot;
		tr[x].l=l;tr[x].r=r;
		if(l==r){tr[x].v=n;return;}
		int mid=l+r>>1;
		tr[x].lc=tot+1;build(l,mid);
		tr[x].rc=tot+1;build(mid+1,r); 
	}
	void down(int x)
	{
		int t=tr[x].tag;
		if(t)
		{
			int lc=tr[x].lc,rc=tr[x].rc;
			tr[lc].tag+=t;tr[rc].tag+=t;
			tr[lc].v-=t;tr[rc].v-=t;
			tr[x].tag=0;
		}
	}
	void modify(int x,int l,int r,int v)
	{
		if(tr[x].l==l&&tr[x].r==r)
		{
			tr[x].v-=v;
			tr[x].tag+=v;
			return;
		}
		down(x);
		int mid=tr[x].l+tr[x].r>>1,lc=tr[x].lc,rc=tr[x].rc;
		if(r<=mid)modify(lc,l,r,v);
		else if(l>mid)modify(rc,l,r,v);
		else modify(lc,l,mid,v),modify(rc,mid+1,r,v);
	}
	int query(int x,int p)
	{
		if(tr[x].l==tr[x].r)return tr[x].v;
		down(x);
		int mid=tr[x].l+tr[x].r>>1,lc=tr[x].lc,rc=tr[x].rc;
		if(p<=mid)return query(lc,p);return query(rc,p);
	}
}T[2];
int main()
{
	n=read();m=read();
	LL ans=(LL)(n-2)*(n-2);
	for(int i=0;i<2;i++)T[i].init(),T[i].build(2,n-1);
//	printf("%d\n",T[0].query(1,2));
	while(m--)
	{
		int o=read()-1,x=read(),r=T[o^1].query(1,x);
		ans-=(r-2);//printf("   %lld %lld\n",r,ans);
		int t=T[o].query(1,2);
		if(x<t&&r!=2)T[o].modify(1,2,r-1,t-x);
		
	}
	printf("%lld",ans);
}


Measured memory_bytes: 22512
import java.util.Scanner;

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

		int H = Integer.parseInt(sc.next());
		int W = Integer.parseInt(sc.next());
		int A = Integer.parseInt(sc.next());
		int B = Integer.parseInt(sc.next());

		sc.close();

		for(int tate = 1;tate <= H;tate++) {
			for(int yoko = 1;yoko <= W;yoko++) {
				if(tate <= B) {
					if(yoko <= A) {
						System.out.print("0");
					}else {
						System.out.print("1");
					}
				}else {
					if(yoko <= A) {
						System.out.print("1");
					}else {
						System.out.print("0");
					}
				}
			}
			System.out.println("");
		}


	}
}

Measured memory_bytes: 43964
n = int(input())
s = input()
alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
alpha2 = "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ"
alpha2 = list(alpha2)
for i in range(len(s)):
  num = alpha.index(s[i])
  s = s[:i]+alpha2[num+n]+s[i+1:]
print(s)

Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            var V = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            var C = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();

            int ans = V.Select((x,idx) => x - C[idx]).Where(x => x > 0).Sum();

            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 13396
#include<cstdio>
#define MAX 10000
#define NIL -1
struct Node{
	int parent,left,right;
};
Node T[MAX];
int n,D[MAX],H[MAX];
void setdepth(int u,int d){
	if(u==NIL) return ;
	D[u]=d;
	setdepth(T[u].left,d+1);
	setdepth(T[u].right,d+1);
}
int setheight(int u){
	int h1=0,h2=0;
	if(T[u].left!=NIL)
	h1=setheight(T[u].left)+1;
	if(T[u].right!=NIL)
	h2=setheight(T[u].right)+1;
	return H[u]=(h1>h2?h1:h2);
}
int getsibling(int u){
	if(T[u].parent==NIL) return NIL;
	if(T[T[u].parent].left!=u&&T[T[u].parent].left!=NIL)
	return T[T[u].parent].left;
	if(T[T[u].parent].right!=u&&T[T[u].parent].right!=NIL)
	return T[T[u].parent].right;
	return NIL;
}
void print(int u){
	printf("node %d: ",u);
	printf("parent = %d, ",T[u].parent);
	printf("sibling = %d, ",getsibling(u));
	int deg=0;
	if(T[u].left!=NIL) deg++;
	if(T[u].right!=NIL) deg++;
	printf("degree = %d, ",deg);
	printf("depth = %d, ",D[u]);
	printf("height = %d, ",H[u]);
	if(T[u].parent==NIL){
		printf("root\n");
	}else if(T[u].left==NIL&&T[u].right==NIL){
		printf("leaf\n");
	}else {
		printf("internal node\n");
	}
}
int main(){
	int v,l,r,root=0;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		T[i].parent=NIL;
	}
	for(int i=0;i<n;i++){
		scanf("%d %d %d",&v,&l,&r);
		T[v].left=l;
		T[v].right=r;
		if(l!=NIL) T[l].parent=v;
		if(r!=NIL) T[r].parent=v;
	}
	for(int i=0;i<n;i++){
		if(T[i].parent==NIL)
		root=i;
	}
	setdepth(root,0);
	setheight(root);
	for(int i=0;i<n;i++)
	print(i);
	return 0;
}


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

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#define TIME cerr << "\nTime elapsed: " << setprecision(5) <<1000.0 * clock() / CLOCKS_PER_SEC << "ms\n";
#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define PI 3.14159265358979323846
#define ll long long

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << "debug statement : " << *it << " = " << a << endl;
    err(++it, args...);
} 

void fastscan(int &number) { 
    bool negative = false; 
    register int c;
    number = 0; 
    c = getchar(); 
    if (c=='-'){
        negative = true;
        c = getchar(); 
    }
    for (; (c>47 && c<58); c=getchar()) 
        number = number *10 + c - 48;
    if (negative) 
        number *= -1; 
} 

class BIT{
public:
    int size;
    vector<int> v;
    BIT(int s){
        size = s;
        v.resize(s, 0);
    }
    void update(int i, int delta){
        while(i < size){
            v[i] += delta;
            i += i & (-i);
        }
    }
    int sum(int i){
        int s = 0;
        while(i > 0){
            s += v[i];
            i -= i & (-i);
        }
        return s;
    }
};

void testCase(){
	string s;
	cin>>s;
	if(s.length() == 6){
		if(s[2] == s[3] && s[4] == s[5]){
			cout<<"Yes"<<endl;
		}
		else{
			cout<<"No"<<endl;
		}
	}
	else{
		cout<<"No"<<endl;
	}
}

int main(){
    FAST
    int t = 1;
    // cin>>t;
    while(t--){
        testCase();
    }
}



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

int main() {
  int N;
  vector<int>a(30);  
  cin >> N;
  for(int i=0; i<N; i++) {
  	cin >> a.at(i);
  }
  int cnt = 0;
  for(int i=1; i<N-1; i++){
    if((a[i]<a[i-1] && a[i]>a[i+1]) || (a[i]>a[i-1] && a[i]<a[i+1])) cnt++;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<iomanip>
#include<list>
#include<deque>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define DEB2(X) cout<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define DEB2(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
//typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define NP(X,Y) next_permutation(X,Y)
#define setdouble(X,Y) cout<<fixed<<setprecision(X)<<Y
int ceil2(int a,int b){if(a%b==0){return a/b;}else{return a/b+1;}}
int pow2(int a,int b){int r=1;for(int i=1;i<=b;i++){r*=a;}return r;}
int Log2(int a){int t=0;while(1){if(a==0||a==1){break;}a/=2;t++;}return t;}

int N;
int A[200010];

signed main(){
	cin>>N;
	int sum=0;
	REP(i,N){
		cin>>A[i];
		sum+=A[i];
		sum%=MOD;
	}
	int ans=0;
	REP(i,N){
		sum=(sum-A[i]+MOD)%MOD;
		ans+=sum*A[i];
		ans%=MOD;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 5180
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let line = read_as_vec::<i64>();
    let (n, x, y) = (line[0], line[1]-1, line[2]-1);
    let mut ans: Vec<u64> = vec![0;n as usize];

    for i in 0..n-1{
        for j in i+1..n{
            ans[
                cmp::min(j-i, cmp::min(
                    (x-i).abs() + 1 + (y-j).abs(),
                    (x-j).abs() + 1 + (y-i).abs()
                )) as usize
            ] += 1;
        }
    }

    for i in 1..n{
        println!("{}", ans[i as usize]);
    }
}


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

namespace ABC051
{
    class Program
    {
        static void Main(string[] args)
        {
            solve();
        }

        static void solve()
        {
            string[] gStr = Console.ReadLine().Split(' ');
            int n = int.Parse(gStr[0]);
            int m = int.Parse(gStr[1]);

            List<int> a = new List<int>();
            List<int> b = new List<int>();
            List<int> c = new List<int>();

            for (int i = 0; i < m; ++i)
            {
                string[] line = Console.ReadLine().Split(' ');
                int tmpa = int.Parse(line[0]);
                int tmpb = int.Parse(line[1]);
                int tmpc = int.Parse(line[2]);

                a.Add(tmpa - 1);
                b.Add(tmpb - 1);
                c.Add(tmpc);
            }

            const int MAX = 999999;
            int[,] dist = new int[n, n];
            for (int i = 0; i < n; ++i)
            {
                for (int j = 0; j < n; ++j)
                {
                    dist[i, j] = MAX;
                }
                dist[i, i] = 0;
            }

            for (int i = 0; i < m; ++i)
            {
                dist[a[i], b[i]] = Math.Min(dist[a[i], b[i]], c[i]);
                dist[b[i], a[i]] = Math.Min(dist[b[i], a[i]], c[i]);
            }

            for (int k = 0; k < n; ++k)
            {
                for (int i = 0; i < n; ++i)
                {
                    for (int j = 0; j < n; ++j)
                    {
                        dist[i, j] = Math.Min(dist[i, j], dist[i, k] + dist[k, j]);
                    }
                }
            }

            int ans = 0;
            for (int i = 0; i < m; ++i)
            {
                if (dist[a[i], b[i]] < c[i])
                    ans++;
            }

            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 3032
#include <bits/stdc++.h>
using namespace std;
#define _MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) _MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define pb push_back
#define all(x) begin(x),end(x)
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#ifdef LOCAL
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cerr<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cerr<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.first<<","<<p.second<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}
#else
#define dbg(...) {}
#endif

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

  using P = pair<int,int>;
  vector<P> ans;

  int bad;

  if(n%2==1){
    bad = n;
  }
  else {
    bad = n+1;
  }

  rep(i,n) rep(j,i+1,n) if(i+j+2 != bad) ans.push_back({i+1, j+1});

  cout << ans.size() << endl;
  for(auto p : ans) cout << p.first << " " << p.second << "\n";

  return 0;
}


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

int main () {
    string S;
    cin >> S;
    
    if (S.at(2)==S.at(3) && S.at(4)==S.at(5)) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3496
import sys
import itertools
# import numpy as np
import time
import math
from heapq import heappop, heappush
from collections import defaultdict
from collections import Counter
from collections import deque
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())
H,W = map(int,readline().split())
A = [list(map(int,readline().split())) for _ in range(H)]
B = [list(map(int,readline().split())) for _ in range(H)]
C = [[abs(A[i][j] - B[i][j]) for j in range(W)] for i in range(H)]
 
X = (H + W) * 80
L = X + X + 1
dp = [[0] * W for _ in range(H)]

# X点持った状態から始める
dp[0][0] |= 1 << (X - C[0][0])
dp[0][0] |= 1 << (X + C[0][0])
for i in range(H):
    for j in range(W):
        if i > 0:
            dp[i][j] |= dp[i - 1][j] << C[i][j]
            dp[i][j] |= dp[i - 1][j] >> C[i][j]
        if j > 0:
            dp[i][j] |= dp[i][j - 1] << C[i][j]
            dp[i][j] |= dp[i][j - 1] >> C[i][j]

ans = L
for i in range(L):
    if dp[-1][-1] & 1 << i > 0:
        ans = min(ans, abs(i - X))
print(ans)


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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;

int main(){
    char a, b; cin >> a >> b;

    if((a == 'H' && b == 'H') || (a != 'H' && b != 'H')) {
        cout << 'H' << endl;
    } else {
        cout << 'D' << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1e9+7;

int main()
{
  int N; cin >> N;

  map<int, ll> prime_factor_cnt;
  for (int i = 2; i <= N; ++i) {

    for (int j = 2, k = i; j <= i; j++) {
      while (k % j == 0) {
        prime_factor_cnt[j]++;
        k /= j;
      }
    }
  }

  ll ans = 1;
  for (auto v : prime_factor_cnt) {
    ans = ans*(v.second+1)%mod;
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;


public class A
{
	public static void Main()
	{
		string[] args = Console.ReadLine().Split(' ');
		int a = Int32.Parse(args[0]);
		int b = Int32.Parse(args[1]);
		int c = Int32.Parse(args[2]);
		int d = Int32.Parse(args[3]);

		bool ans = 
			(Math.Abs(a-c) <= d) || 
			((Math.Abs(a-b) <= d) && (Math.Abs(b-c) <= d));
		Console.WriteLine(ans ? "Yes" : "No");
	}
}





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

#define pb push_back
#define PI 3.141592653589793238

vector<int> tree[1000000];


int main()
{
	int n;
	cin>>n;
	for(int i = 1; i<n; i++)
	{
		int temp;
		cin>>temp;
		tree[temp-1].pb(i);
	}

	for(int i=0; i<n; i++)
	{
		cout<<tree[i].size()<<endl;
	}
}



Measured memory_bytes: 33364
//116
#include<iostream>
#include<utility>
#include<string>
#include<vector>
#include<algorithm>
#include<deque>
#include<queue>
#include<set>
#include<map>
#include<functional>

using namespace std;
#define LL long long
#define ALF "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define LLBIG 1999999999999999999LL
#define INTBIG 1111111111
#define MOD 1000000007
#define PI pair<int,int>
#define VI vector<int>
#define VVI vector<vector<int>>

int H, W, h, w, A, B, C;

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

	cout << A*B/2 << endl;



	return 0;
}

Measured memory_bytes: 256