akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
*/


const long long mod =1e9+7 ;
const int N = 1e6+5;


#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define ll long long
#define fr(i,l,m) for(int i=l;i<m;i++)
# define vii vector<int>
#define vpr vector<pair<int,int> >
#define dbg(x) cout << #x << " is " << x << endl;
#define spk(x) cout<<x<<endl;
#define inf INT_MAX
/*
stoi - sting to int;pow(2,20)->1e6;pow(2,30)->1e9;
stol - string to long;
stoll - string to ll;
*/
ll pwr(ll x,ll y);
////
////
////

int a[25][25],dp[1<<22];

////
///
int main()
{
ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

int n;
cin>>n;
fr(i,1,n+1)
{
    fr(j,1,n+1)
    {
        cin>>a[i][j];
    }
}

dp[0]=1;
fr(i,1,n+1)
{
    for(int bm=1;bm<(1<<n);bm++){
    int l=__builtin_popcount(bm);
    //dbg(l)
    if(l==i)
    {
        fr(k,1,n+1){

        if(bm&(1<<k-1) && a[i][k])
        {
            dp[bm]+=dp[bm^(1<<k-1)];
             dp[bm]%=mod;
        }

        }
    }

    }
}
cout<<dp[(1<<n)-1]<<endl;
return 0;

 }
ll pwr(ll x,ll y)
{
    ll ans=1;
    x=x%mod;
    while(y>0){
    if(y&1)ans=(x*(ans%mod))%mod;
    x=(x*x)%mod;
    y=y/2;

    }
    return ans%mod;
}



Measured memory_bytes: 10496
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>
#include <map>

typedef long long ll;
#define rep(i, a, n) for(int i = a; i<n; i++)
#define ALL(a) begin(a), end(a)
#define mii map<int, int>
#define msi map<string, int>
#define vi vector<int>
#define vl vector<ll>
#define MOD 1000000007
#define INF 1e9
#define showVector(v) rep(i,0,v.size()){p(v[i]);p(" ")} pl("")
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
using namespace std;

// 素数判定 O(√n)
bool is_prime(int n){
    for(int i = 2; i * i <= n; i++){
        if(n % i == 0) return false;
    }
    return true;
}
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;

}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main() {
    string S;
    cin >> S;
    string left;
    string right;
    left = S.substr(0, 2);
    right = S.substr(2, 2);
    int li = stoi(left);
    int ri = stoi(right);
    if ((li >= 13 || li == 0) && ri <= 12 && ri >= 1) {
        cout << "YYMM" << endl;
    } else if (li >= 1 && li <= 12 && (ri >= 13 || ri == 0)) {
        cout << "MMYY" << endl;
    } else if (li >= 1 && li <= 12 && ri >= 1 && ri <= 12) { 
        cout << "AMBIGUOUS" << endl;
    } else {
        cout << "NA" << endl;
    }
    return 0;
}

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

int main() {
  int N,M;
  cin >> N >> M;
  vector<int> vec(N);
  int c;
  for(int i = 0; i < M * 2; i++) {
    cin >> c;
    vec.at(c - 1) += 1;
  }
  for(int i = 0; i < N; i++) {
    cout << vec.at(i) << endl;;
  }
}


Measured memory_bytes: 3576
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <iomanip>
#include <ctype.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

using namespace std;
using ll = long long;
using PAIR = pair<int, int>;
using PAIRLL = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;

namespace mp = boost::multiprecision;
using Bint = mp::cpp_int;
using boost::multiprecision::cpp_dec_float_100;

#define rep(i,N) for(int i=0;i<(int)N;++i)

ll GCD(ll x, ll y) {
    if (y == 0) return x;
    else return GCD(y, x % y);
}

ll LCM(ll x, ll y) {
    return x / GCD(x, y) * y;
}

bool my_compare(pair<string, int> a, pair<string, int> b) {
    if (a.first != b.first) {
        return a.first < b.first;
    }

    if (a.second != b.second) {
        return a.second > b.second;
    }
    else {
        return true;
    }
}

int main()
{
    ll A, B, C, K;
    cin >> A >> B >> C >> K;

    if (K < A) { cout << K << endl; }
    else if (K >= A && K <= A + B) { cout << A << endl; }
    else { cout << A - (K - A - B) << endl; }
}

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

#define inf 2000000000
#define INF 1e18

typedef long long ll;
typedef long double ld;
typedef double db;
typedef string str;

typedef pair<ll,ll> ii;
typedef pair<ii,ll> iii;
typedef vector<ll> vl;
typedef vector<ii> vii;

#define getbit(n,i) (((n)&(1LL<<(i)))!=0)
#define setbit0(n,i) ((n)&(~(1LL<<(i))))
#define setbit1(n,i) ((n)|(1LL<<(i)))
#define togglebit(n,i) ((n)^(1LL<<(i)))
#define lastone(n) ((n)&(-(n)))
#define read freopen("debug\\in.txt","r",stdin)
#define write freopen("debug\\out.txt","w",stdout)
#define fi first
#define se second
#define getI(a) scanf("%d",&a)
#define getII(a,b) scanf("%d%d",&a,&b)
#define PI (acos(-1))
#define fastread ios_base::sync_with_stdio(false);cin.tie(NULL)
#define mod (1000000007)
#define asz 500005
#define lb lower_bound
#define ub upper_bound
#define sz(x) (ll)x.size()
#define all(x) begin(x), end(x)
#define f0r(i, a) for (ll i=0; i<a; i++)
#define FOR(i, a) for (ll i=1; i<=a; i++)
#define pb push_back
#define ppf pop_front
#define ppb pop_back
#define pf push_front

ll a[105];

int main()
{
    ll n,m,t,i,j,b,w;
    cin>>t;
    if(t<30) cout<<"No\n";
    else cout<<"Yes\n";
}    


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define null NULL
#define mp make_pair
#define pb(a) push_back(a)
#define sz(a) ((int)(a).size())
#define all(a) a.begin() , a.end()
#define fi first
#define se second
#define relaxMin(a , b) (a) = min((a),(b))
#define relaxMax(a , b) (a) = max((a),(b))
#define SQR(a) ((a)*(a))
#define PI 3.14159265358979323846
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;

const int MAXN = 100010;

int n, m;
vector<pair<pii, int>> cons;
vector<pii> fo[MAXN];

set<int> known;
int x[MAXN];

void Propagate(int vr, int dist){
  x[vr] = dist;
  known.insert(vr);

  for(const auto& e : fo[vr]){
    int to = e.fi;
    int diff = e.se;
    if(!known.count(to))
      Propagate(to, dist + diff);
  }
}

int main(){
  scanf("%d%d", &n, &m);
  cons.resize(m);
  for(int i = 0;i < m;++i){
    scanf("%d%d%d", &cons[i].fi.fi, &cons[i].fi.se,
                    &cons[i].se);
    --cons[i].fi.fi;
    --cons[i].fi.se;

    fo[cons[i].fi.fi].pb(mp(cons[i].fi.se, cons[i].se));
    fo[cons[i].fi.se].pb(mp(cons[i].fi.fi, -cons[i].se));
  }

  for(int i = 0;i < n;++i)
    if(!known.count(i))
      Propagate(i, 0);

  bool fine = true;
  for(int i = 0;i < m;++i){
    int a = cons[i].fi.fi;
    int b = cons[i].fi.se;
    int c = cons[i].se;
    if(x[b] - x[a] != c) fine = false;
  }

  printf(fine ? "Yes\n" : "No\n");

  return 0;
}


Measured memory_bytes: 18944
#include <iostream>
#include <string>
using namespace std;
int main()
{
    string a;
    cin >> a;
    for(int i = 0;i < 4;i++)
    {
        cout << a[i];
    }
    cout << " ";
    for(int i = 4;i < 12;i++)
    {
        cout << a[i];
    }
    cout << endl;
    return 0;
}

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

int main(){
    int N, M, A;
    long long ans = 0;
    cin >> N >> M;
    pair<int, int> CB[M];
    priority_queue<int, vector<int>, greater<int>> desc;
    
    for(int i=0; i<N; i++){
	cin >> A;
	desc.push(A);
    }
    for(int i=0; i<M; i++)
	cin >> CB[i].second >> CB[i].first;
    
    sort(CB, CB+M);
    for(int i=M-1; i>=0; i--){
	if(CB[i].first <desc.top())
	    break;
	
	for(int j=0; j<CB[i].second; j++){
	    if(desc.top() < CB[i].first){
		desc.pop();
		desc.push(CB[i].first);
	    }
	    else break;
	}	
    }
    
    while(!desc.empty()){
	ans +=  desc.top();
	desc.pop();
    }
    cout << ans << endl;
}



Measured memory_bytes: 1660
#include <bits/stdc++.h>
        using namespace std;
   #define int long long
const int MAX = 510000;
const int MOD = 1000000007;

  int modpow(int a, int n, int mod) {
    int res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
     signed main(){
    int n,t=0;
    cin>>n;
    int a,b;
    map<pair<int,int>,int> mp;
     for(int i=0;i<n;i++){
          cin>>a>>b;
           // cerr<<a<<' '<<b;
          if(a==0&&b==0){t++;continue;}
          if(a==0){mp[make_pair(0,1)]++;continue;}
          if(b==0){mp[make_pair(1,0)]++;continue;}
          int p=a,q=b;
          a=abs(a);b=abs(b);
          //cerr<<a<<' '<<b;
          if(a>b)swap(a,b);
          while(a!=0){
               b%=a;
               swap(a,b);
          }

          if(p<0){
               p*=-1;q*=-1;
          }
          mp[make_pair(p/b,q/b)]++;
     }
     int ans=1;
     for(auto i=mp.begin();i!=mp.end();i++){
          if(i->second==0)continue;
          if((i->first).first==0||(i->first).second==0){
               ans=(ans*((MOD+modpow(2,mp[make_pair(0,1)],MOD)+modpow(2,mp[make_pair(1,0)],MOD)-1)%MOD))%MOD;
               mp[make_pair(0,1)]=0;
               mp[make_pair(1,0)]=0;
          }
         if((i->first).second<0) {ans=(ans*((MOD+modpow(2,i->second,MOD)+modpow(2,mp[make_pair(-1*(i->first).second,(i->first).first)],MOD)-1)%MOD))%MOD;
        // cerr<<mp[make_pair(-1*(i->first).second,(i->first).first)];
          mp[make_pair(-1*(i->first).second,(i->first).first)]=0;
         }
         else{  ans=(ans*((MOD+modpow(2,i->second,MOD)+modpow(2,mp[make_pair((i->first).second,-1*(i->first).first)],MOD)-1)%MOD))%MOD;
    // cerr<<mp[make_pair((i->first).second,-1*(i->first).first)];
      mp[make_pair((i->first).second,-1*(i->first).first)]=0;}
     }
     cout<<(MOD+ans-1+t)%MOD<<endl;

      }

        

Measured memory_bytes: 28556
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1000000009
typedef long long ll;
#define REP(i,n) for(int i=0;i<(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define rollcall cout<<"I'm Sucu."<<endl;
#define YES(s) s?cout << "YES" << endl:cout << "NO" << endl
#define Yes(s) s?cout << "Yes" << endl:cout << "No" << endl
#define Taka(s) s?cout << "Takahashi" << endl:cout << "Aoki" << endl
#define out(s,t,u) s?cout << t << endl:cout << u << endl
#define int ll
#define Endl endl


signed main(){
    int N;
    int a[114514];
    int b[3]={};
    cin >> N;
    REP(i,N){
        cin >>a[i];
        if(a[i]%2==1){
            b[0]++;
        }else if(a[i]%4!=0){
            b[1]++;
        }else{
            b[2]++;
        }
    }
    //cout<<b[0]<<" "<<b[1]<< " "<<b[2]<<endl;
    if(b[1]!=0){
        Yes(b[0]<=b[2]);
    }else{
        Yes(b[0]<=b[2]+1);
    }
    return 0;
}   



Measured memory_bytes: 1024
//AtCoder 
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;
int main() {
#if LOCAL&0
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif
    ll n; cin>>n;
    vector<ll> pn(n);
    for(auto&& p:pn){
        cin>>p;
    }
    ll ans=0;
    for(ll i=1;i<pn.size()-1;++i){
        vector<ll> tmp(3);
        tmp[0]=pn[i-1];
		tmp[1]=pn[i];
       	tmp[2]=pn[i+1];
        sort(tmp.begin(),tmp.end());
        if(tmp[1]==pn[i] && tmp[0]!=pn[i]) ++ans;
	}
    cout<<ans<<endl;
    return 0;
}

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

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

	for (int i = a; i <= b; i++) {
		if (i < a + k || b - k < i) cout << i << endl;
		else if (i == a + k) i = b - k;
	}

	return 0;
}

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

int main(){
  int sum = 0;
  int tmp_a, tmp_b;
  std::string a, b;
  std::cin >> a >> b;
  
  sum =1 + (b[0]-'0') * 100 + (b[1]-'0') * 10 + (b[2]-'0') - ((a[0]-'0') * 100 + (a[1]-'0') * 10 + (a[2]-'0'));
  if(((a[0]-'0') + (a[1]-'0') * 10) - ((a[3]-'0') * 10 + (a[4]-'0')) < 0){
    sum--;
  }
  if(((b[0]-'0') + (b[1]-'0') * 10) - ((b[3]-'0') * 10 + (b[4]-'0')) > 0){
    sum--;
  }
  
  std::cout << sum << std::endl;
  return 0;
}

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

int N;
vector<int> A(20);

bool solve(int i, int m)
{
    if(m == 0) return true;
    if(i >= N) return false;
    bool res = solve(i+1, m) || solve(i+1, m-A[i]);
    return res;
}

int main()
{
    // 入力
    cin >> N;
    for(int i = 0; i < N; i++) cin >> A[i];
    int M;
    cin >> M;

    // 判定
    vector<bool> ans(M);
    for(int i = 0; i < M; i++)
    {
        int m;
        cin >> m;
        bool judge = solve(0, m);
        ans[i] = judge;
    }

    // 解を出力
    for(int i = 0; i < M; i++)
    {
        if(ans[i] == true) cout << "yes" << endl;
        else cout << "no" << endl;
    }
    return 0;
}


Measured memory_bytes: 3096
use proconio::{input, fastout};
use std::collections::HashSet;

macro_rules! echo {
  ($val:expr) => {
    println!("{}", $val);
  }
}

#[fastout]
fn main() {
  input!{
    x: i32,
    n: usize,
    ps: [i32; n]
  };

  let mut ans = 201;
  let mut set = HashSet::new();
  for p in ps {
    set.insert(p);
  }
  for i in 0..102 {
    if set.contains(&i) {
      continue;
    }
    if (ans - x).abs() > (i - x).abs() {
      ans = i;
    }
  }
  echo!(ans);
}


Measured memory_bytes: 2156
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

int main() {
    string s;
    cin >> s;
    int n = s.size();

    vector<ll> dp0(n+1);  /* dp0[i+1] : aおよびbの上からi桁目(iは0-index)までを確定させ、
                                         その時点ではまだa+bがs未満になるかわかっていない
                                         (a, b)の組の個数 */
    
    vector<ll> dp1(n+1);  /* dp1[i+1] : aおよびbの上からi桁目(iは0-index)までを確定させ、
                                         その時点で既にa+bがs未満であることがわかっている
                                         (a, b)の組の個数 */

    dp0[0] = 1;
    rep(i, n) {

        // (a_i, b_i) = (0, 0) の場合
        if(s[i] == '0') {
            dp0[i+1] = dp0[i];
            dp1[i+1] = dp1[i];
        }
        else if(s[i] == '1') {
            dp1[i+1] = dp0[i] + dp1[i];
        } 
        
        // (a_i, b_i) = (0, 1), (1, 0) の場合
        if(s[i] == '0') {
            dp1[i+1] += 2*dp1[i];
        }
        else if(s[i] == '1') {
            dp0[i+1] += 2*dp0[i];
            dp1[i+1] += 2*dp1[i];
        }
        dp0[i+1] %= mod;
        dp1[i+1] %= mod;
    }

    cout << (dp0[n] + dp1[n])%mod << endl;
    return 0;
}

Measured memory_bytes: 2048
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
    int N,M,ans=0;
    cin>>N;
    vector<string> blue(N,"");
    REP(i,N)cin>>blue[i];
    cin>>M;
    vector<string> red(M,"");
    REP(i,M)cin>>red[i];
    REP(i,N){
        int tm=1;
        REP(y,N)if(y!=i&&blue[i]==blue[y])tm++;
        REP(y,M)if(blue[i]==red[y])tm--;
        ans=max(ans,tm);
    }
    cout<<ans<<endl;
}

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

const long long MOD = 1e9 + 7;

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

    long long c[2020][2020];
    for (int i = 0; i <= n; i++) {
        c[i][0] = 1;    
        for (int j = 1; j <= i; j++) {
            c[i][j] = (c[i - 1][j - 1] + c[i - 1][j]) % MOD;
        }
    }

    for (int i = 1; i <= k; i++) {
        cout << (c[n - k + 1][i] * c[k - 1][i - 1]) % MOD << endl;
    }

    return 0;
}

Measured memory_bytes: 31360
// Segment Tree- Lazy Propagation

#include <iostream>
#include <vector>
#define MAXN 200005
#define lson (idx << 1)
#define rson (idx << 1 | 1)

using namespace std;
typedef long long ll;

struct Node {
  int l, r, hi, lazy = 0;
};

struct SegTree {
  Node s[MAXN << 2];
  void calc(int idx) { s[idx].hi = max(s[lson].hi, s[rson].hi); }

  void pushdown(int idx) {
    if (s[idx].lazy) {
      for (int i = lson; i <= rson; ++i) {
        if (s[i].hi > s[idx].lazy) {
          s[i].hi = s[idx].lazy;
          s[i].lazy = s[idx].lazy;
        }
      }
    }
    s[idx].lazy = 0;
  }

  void build(int idx, int l, int r, vector<int> &a) {
    s[idx].l = l, s[idx].r = r;
    if (l == r) {
      s[idx].hi = a[l];
      return;
    }
    int mid = (l + r) >> 1;
    build(lson, l, mid, a);
    build(rson, mid + 1, r, a);
    calc(idx);
  }

  void update(int idx, int l, int r, int x) {
    if (s[idx].hi <= x)
      return;
    if (s[idx].l >= l && s[idx].r <= r) {
      s[idx].hi = x;
      s[idx].lazy = x;
      return;
    }
    pushdown(idx);
    int mid = (s[idx].l + s[idx].r) >> 1;
    if (l <= mid)
      update(lson, l, r, x);
    if (mid + 1 <= r)
      update(rson, l, r, x);
    calc(idx);
  }

  int query(int idx, int l, int r) {
    if (s[idx].l >= l && s[idx].r <= r)
      return s[idx].hi;
    pushdown(idx);
    int ans = 0;
    int mid = (s[idx].l + s[idx].r) >> 1;
    if (l <= mid)
      ans = max(ans, query(lson, l, r));
    if (mid + 1 <= r)
      ans = max(ans, query(rson, l, r));
    return ans;
  }
};

int main() {
  int n, q;
  cin >> n >> q;
  vector<int> col(n + 1, n), row(n + 1, n);
  col[n] = 1, row[n] = 1;
  SegTree C, R;
  C.build(1, 1, n, col);
  R.build(1, 1, n, row);
  ll ans = (ll)(n - 2) * (n - 2);
  for (int i = 0; i < q; ++i) {
    int t, x;
    cin >> t >> x;
    if (t == 1) {
      int hi = C.query(1, x, x);
      ans -= hi - 2;
      R.update(1, 1, hi, x);
      C.update(1, x, x, 1);
    } else {
      int hi = R.query(1, x, x);
      ans -= hi - 2;
      C.update(1, 1, hi, x);
      R.update(1, x, x, 1);
    }
  }
  cout << ans;
}

Measured memory_bytes: 29884
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef map<char,int> M;
const ll mod=1000000000+7;

int main(){
    int K,X;
    cin>>K>>X;
    for(int i=max(-1000000,X-K+1);i<=min(1000000,X+K-1);i++){
        cout<<i<<" ";
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
using ll = long long;
 
int main(){
  ll n,k;
  int cnt = 0;
  cin >> n >> k;
  for(int i = 0; i < n; i++){
    ll x,y;
    cin >> x >> y;
    if(sqrt(x*x+y*y) <= k){
      cnt++;
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 3696
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int INF = 1e9;
int MOD = 1e9+7;
main(){
    string S;
    cin >> S;
    if(S[0] == '9' || S[1] == '9'){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	if(s == "ABC") cout << "ARC" << endl;
	else cout << "ABC" << endl;
}

Measured memory_bytes: 3648
import sys

n, m = map(int, input().split())
s = [0]*m
c = [0]*m
for i in range(m):
    s[i], c[i] = map(int, input().split())
ans = [-1]*n
flag = [False]*n
for si, ci in zip(s, c):
    if flag[si-1]:
        if ans[si-1] != ci:
            print(-1)
            sys.exit()
    else:
        ans[si-1] = ci
        flag[si-1] = True
if ans[0] == 0:
    if n == 1:
        print(0)
        sys.exit()
    else:
        print(-1)
        sys.exit()
for i in range(n):
    if ans[i] == -1:
        if i == 0 and n == 1:
            print(0)
            sys.exit()
        elif i == 0 and n != 1:
            ans[i] = 1
        else:
            ans[i] = 0
for a in ans:
    print(a, end='')
print()

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

int main() {

    while(true){

        int n;

        cin >> n;

        if(n == 0){
            break;
        }

        int ma=-1,mi=1001,sums=0;

        for(int i=0; i<n; i++){
            int input;
            cin >> input;
            sums += input;
            if(ma < input){
                ma = input;
            }
            if(mi > input){
                mi = input;
            }
        }

        sums -= ma + mi;
        cout << sums/ (n-2) << endl;

    }

    return 0;
}


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define fastIO (cin.tie(0), cout.tie(0), ios::sync_with_stdio(false))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define precise(i) fixed << setprecision(i)
using lint = long;
using llint = long long;
using namespace std;

bool isVowel(char ch) {
    return ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u';
}

int main() {
    fastIO;

    char ch;
    cin >> ch;
    if (isVowel(ch))
        cout << "vowel" << endl;
    else
        cout << "consonant" << endl;
}


Measured memory_bytes: 3640
import re

p = input()
a = 'keyence'

if p[:7] == a or p[:6] + p[-1:] == a or p[:5] + p[-2:] == a or p[:4] + p[-3:] == a or p[:3] + p[-4:] == a or p[:2] + p[-5:] == a or p[0] + p[-6:] == a or p[-7:] == a:
    print('YES')
else:
    print('NO')

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,a; cin>>n>>a;
    if (n%500<=a){
        cout<<"Yes\n";
    }else{
        cout<<"No\n";
    }
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <string>
#include <vector>

using namespace std;

int main() {
  // vector<int> X(5);
  // int x1, x2, x3, x4, x5;
  int N;
  cin >> N;

  int r = N % 1000;

  if (r == 0) {
    cout << 0 << endl;
    return 0;
  }

  cout << (1000 - r) << endl;
  return 0;
}


Measured memory_bytes: 3188
import java.util.Scanner;
public class Main {

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

		int n = stdIn.nextInt();
		int n2 = n;

		char[] a = stdIn.next().toCharArray();
	

		for(int i = 0; i < n-1; i++) {
			if(a[i] == a[i+1]) {
				n2--;
			}
		}
		System.out.println(n2);
	}

}


Measured memory_bytes: 25832
from collections import deque

H, W, K = map(int, input().split())
A = [[0 for _ in range(W)] for _ in range(H)]
for i in range(H):
    A_i_x = input()
    for j in range(W):
        A[i][j] = A_i_x[j]
        if A_i_x[j] == 'S':
            start_h = i
            start_w = j

dist_from_exit = [[0 for _ in range(W)] for _ in range(H)]
for i in range(H):
    for j in range(W):
        dist_from_exit[i][j] = min(i, j, H - 1 - i, W - 1 - j)

queue = deque()
queue.append([start_h, start_w])
visited = [[-1 for _ in range(W)] for _ in range(H)]
visited[start_h][start_w] = 0
dx = [1, 0, -1, 0]
dy = [0, 1, 0, -1]
dist_left_cand = [dist_from_exit[start_h][start_w]]
while queue:
    h, w = queue.pop()
    for i in range(4):
        if 0 <= h + dy[i] <= H-1 and 0 <= w + dx[i] <= W-1:
            if visited[h + dy[i]][w + dx[i]] == -1 and A[h + dy[i]][w + dx[i]] == '.' and visited[h][w] < K:
                queue.appendleft([h + dy[i], w + dx[i]])
                visited[h + dy[i]][w + dx[i]] = visited[h][w] + 1
                dist_left_cand.append(dist_from_exit[h + dy[i]][w + dx[i]])

dist_left_min = min(dist_left_cand)
print((dist_left_min - 1) // K + 1 + 1)


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

const int MAX_N = 100010;
int main(void) {
	int N, M; cin >> N >> M;
	vector<int> H(N), v(N);

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

	for (int i = 0; i < M; i++) {
		int a, b; 
		cin >> a >> b;
		a--; b--;
		v[a] = max(v[a], H[b]);
		v[b] = max(v[b], H[a]);
	}

	int ans = 0;
	for (int i = 0; i < N; i++) {
		if (H[i] > v[i]) ans++;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 4060
n, m = map(int, input().split())
bulbs = []
for _ in range(m):
    _, *s = list(map(int, input().split()))
    bulbs.append(s)
ps = list(map(int, input().split()))

count = 0
for i in range(2**n):
    switches = []
    for _ in range(n):
        switches.append(i % 2)
        i //= 2
    ok = True
    for s, p in zip(bulbs, ps):
        res = p
        for b in s:
            res += switches[b - 1]
        if res % 2 == 1:
            ok = False
    if ok:
        count += 1
print(count)

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

int main(){
    int n,m;
    cin >>n>>m;
    
    vector<vector<int>> connect(n);
    int a,b;
    
    rep(i,m){
        cin >> a >> b;
        connect[a-1].push_back(b-1);
        connect[b-1].push_back(a-1);
    }
    
    vector<int> reach(n,-1);
    reach[0]=0;
    
    queue<int> q;
    q.push(0);
    
    while(!q.empty()){
        for(int i : connect[q.front()]){
            if(reach[i]==-1){
                reach[i] = q.front();
                q.push(i);
            }
        }
        q.pop();
    }
    
    cout << "Yes" << endl;
    for(int i=1; i<n; i++){
        cout << reach[i]+1 << endl;
    }
    return 0;
}


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

int a[30];
int b[30];


int main()
{
	int M, N, C,x;

	cin >> N >> M >> C;

	
	for (int i = 0; i < M; i++)
	{
		cin >> x;
		b[i] = x;
	}

	int count = 0;

	for (int i = 0; i < N; i++)
	{
		int ans = 0;

		for (int j = 0; j < M; j++)
		{
			cin >> x;
			ans += x * b[j];
		}

		if (ans + C> 0)
		{
			count++;
		}		
	}


	cout << count;
}


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

using namespace std;
int main(){
    int n,t,m,k=0,x=1008;
    cin>>n>>t;
    int r[n],b[n];
    for(int i=0 ;i<n;i++){
        cin>>r[i]>>b[i];
        if(b[i]<=t){

            if(r[i]<x){
                x=r[i];
                m=i;
                k=1;
            }
            if(r[i]==x && b[i]<b[m]){
                x=r[i];
                m=i;
                k=1;

            }
        }
    }
    if(k==0) cout<<"TLE"<<endl;
    else cout<<x<<endl;
return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<vector>
#include<queue>
#include<map>
#include<bitset>
#include<set>
#define N (200010)
#define P ()
#define M (N<<1)
#define inf (0x7f7f7f7f)
#define rg register int
#define Label puts("NAIVE")
#define spa print(' ')
#define ent print('\n')
#define rand() (((rand())<<(15))^(rand()))
#define file(s) freopen(s".in","r",stdin),freopen(s".out","w",stdout)
typedef long double ld;
typedef long long LL;
typedef unsigned long long ull;
using namespace std;
namespace fastIO1{
	inline char read(){
		static const int IN_LEN=1000000;
		static char buf[IN_LEN],*s,*t;
		return (s==t?t=(s=buf)+fread(buf,1,IN_LEN,stdin),(s==t?-1:*s++):*s++);
	}
	template<class T>
	inline void read(T &x){
		static bool iosig;
		static char c;
		for(iosig=false,c=read();!isdigit(c);c=read()){
			if(c=='-')iosig=true;
			if(c==-1)return;
		}
		for(x=0;isdigit(c);c=read())x=((x+(x<<2))<<1)+(c^'0');
		if(iosig)x=-x;
	}
	inline char readc(char &c){
		for(c=read();!isalpha(c)&&!isdigit(c);c=read())
		if(c==-1)return 0;
	}
	const int OUT_LEN = 10000000;
	char obuf[OUT_LEN],*ooh=obuf;
	inline void print(char c) {
		if(ooh==obuf+OUT_LEN)fwrite(obuf,1,OUT_LEN,stdout),ooh=obuf;
		*ooh++=c;
	}
	template<class T>
	inline void print(T x){
		static int buf[30],cnt;
		if(x==0)print('0');
		else{
			if(x<0)print('-'),x=-x;
			for(cnt=0;x;x/=10)buf[++cnt]=x%10+48;
			while(cnt)print((char)buf[cnt--]);
		}
	}
	inline void flush(){fwrite(obuf,1,ooh-obuf,stdout);}
}
namespace fastIO2{
	template<class T>
	inline void read(T &x){
		static bool iosig;
		static char c;
		for(iosig=false,c=getchar();!isdigit(c);c=getchar()){
			if(c=='-')iosig=true;
			if(c==-1)return;
		}
		for(x=0;isdigit(c);c=getchar())x=((x+(x<<2))<<1)+(c^'0');
		if(iosig)x=-x;
	}
}
using namespace fastIO1;
int n,E,fi[N],ne[M],b[M]; char str[N];
int f[N],sf[N],siz[N],mn[N]; LL ans;
void add(int x,int y){
	ne[++E]=fi[x],fi[x]=E,b[E]=y;
}
void dfs1(int u,int pre){
//	cout<<u<<endl;
	if(str[u]=='1')mn[u]=0,siz[u]=1;
	else mn[u]=inf;
	for(int i=fi[u];i;i=ne[i]){
		int v=b[i];
		if(v==pre)continue;dfs1(v,u),siz[u]+=siz[v];
		if(f[v]+1>f[u])sf[u]=f[u],f[u]=f[v]+1;
		else sf[u]=max(sf[u],f[v]+1);
		if(siz[v])mn[u]=min(mn[u],f[v]+1);
	}
}
void dfs2(int u,int pre){
//	cout<<u<<endl;
	int tmp=min(f[u]-1,sf[u]+1);
	if(tmp>=mn[u])ans+=(LL)tmp-mn[u]+1;
//	cout<<tmp<<" "<<u<<" "<<mn[u]<<endl;
	for(int i=fi[u];i;i=ne[i]){
		int v=b[i]; if(v==pre)continue;
		int len=(f[u]==f[v]+1)?sf[u]+1:f[u]+1;
		if(f[v]<len)sf[v]=f[v],f[v]=len;
        else sf[v]=max(sf[v],len);
        if(siz[v]<siz[1])mn[v]=min(mn[v],len);
        dfs2(v,u);
	}
}
int main(){
	read(n);
	for(int i=1;i<n;i++){
		int x,y;
		read(x),read(y);
		add(x,y),add(y,x);
	}
	for(int i=1;i<=n;i++)readc(str[i]);
	dfs1(1,0),dfs2(1,0);
	cout<<ans+1;
}

Measured memory_bytes: 16512
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
bool isprime(Int x){
  if(x<=1) return 0;
  for(Int i=2;i*i<=x;i++)
    if(x%i==0) return 0;
  return 1;
}
signed main(){
  const Int n=2e5;
  vector<Int> s(n);
  for(Int i=1;i<n;i++)
    s[i]=s[i-1]+((i&1)&&isprime(i)&&isprime((i+1)/2));
  Int q;
  cin>>q;
  
  for(Int i=0;i<q;i++){
    Int l,r;
    cin>>l>>r;
    cout<<s[r]-s[l-1]<<endl;
  }
  return 0;
}


Measured memory_bytes: 2176
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author cherrypi59
 */

#pragma GCC optimize ("O2")
#pragma GCC optimize ("tree-vectorize")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define FFOR(i, a, b) FOR(i, a, b+1)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) FOR(i, 1, n+1)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define LEN(x) (int)(x).size()
#define DUMP(x) cerr<<__LINE__<<' '<<#x<<"="<<(x)<<endl;
#define popcnt(x) __builtin_popcount(x)
#define popcntll(x) __builtin_popcountll(x)
#define pb push_back
#define eb emplace_back
#define mp make_pair

using namespace std;
using lint = long long;
using pii =  pair<int, int>;
using pll =  pair<lint, lint>;
template <typename T> using vc = vector<T>;
template <typename T> using vvc = vector<vector<T>>;
template <typename T> inline bool chmax(T &a, T b){if(a<b){a = b; return true;} return false;}
template <typename T> inline bool chmin(T &a, T b){if(a>b){a = b; return true;} return false;}

constexpr lint ten(int n) {return n==0 ? 1 : ten(n-1)*10;}

class CFennecVsMonster {
public:
    void solve(std::istream& in, std::ostream& out){
        ios_base::sync_with_stdio(false);
        in.tie(nullptr), out.tie(nullptr);
        int N, K;
        in>>N>>K;
        vc<lint> H(N);
        REP(i, N) in>>H[i];
        sort(RALL(H));
        lint ans = 0;
        REP(i, N){
            if(i>=K) ans += H[i];
        }
        out<<ans<<'\n';
    }
};


int main() {
	CFennecVsMonster solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 4784
Module Program
    Sub Main(args As String())
        Dim K = Integer.Parse(Console.ReadLine())

        Dim x = 0
        For i = 1 To K
            x *= 10
            x += 7
            x = x Mod K
            If x = 0 Then
                Console.WriteLine(i)
                Return
            End If
        Next

        Console.WriteLine(-1)
    End Sub
End Module

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

int main() {
    string S;
    cin >> S;
    int l, m, n;
    l = count(S.begin(), S.end(), 'a');
    m = count(S.begin(), S.end(), 'b');
    n = count(S.begin(), S.end(), 'c');
    if (l+m+n==1) cout << "YES" << endl;
    else if (max(max(l, m), n) - min(min(l, m), n) <= 1) cout << "YES" << endl;
    else cout << "NO" << endl;
}


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

int main() {
  int N;
  cin >> N;
  vector <int> A(N);
  for (int i=0;i<N;i++){
  cin >> A.at(i);
  }
  sort (A.begin(),A.end());
  cout << A.at(N/2)-A.at(N/2-1) << endl;
 }

Measured memory_bytes: 640
#include<bits/stdc++.h>
using ll = long long;
#define int ll
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
signed main(){
    int n,w,z; cin>>n>>w>>z;
    vector<int>v(n); rep(i,n)cin>>v[i];
    if(n==1){
        cout<<abs(v[0]-z)<<endl;
    }else{
        cout<<max(abs(v[n-2]-v[n-1]),abs(v[n-1]-z))<<endl;
    }
}


Measured memory_bytes: 256
n = int(input())

L,score = [],[]
for i in range(n):
    L.append(list(map(int,input().split())))
    
for i in range(n):
    score.append(list(map(int,input().split())))

ans = -10**32
 
for k in range(1,1<<10):
    sc = 0
    
    for i in range(n):
        cnt = 0
        for j in range(10):
            if L[i][j] and k>>j&1:
                cnt +=1
        #print(L[i],v,cnt,i,score,score[i][cnt])
        sc += score[i][cnt]
            #print(L[i],v,cnt,i,score,score[i][cnt])
    ans = max(ans,sc)

print(ans)

Measured memory_bytes: 9216
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pii;
typedef tuple<ll, ll, ll> ti;
 
#define REP(a,b,c) for(ll a=b;a<(c);a++)
#define PER(a,b,c) for(ll a=b;a>=(c);a--)
 
inline ll ii(){ ll x; cin >> x; return x; }
inline string is(){ string x; cin >> x; return x; }
inline ld id(){ ld x; cin >> x; return x; }
inline void oi(ll x){ cout << x; }
inline void od(ld x){ cout << fixed << setprecision(10) << x; }
inline void os(string x){ cout << x; }
inline void oe(){ cout << endl; }
inline void oie(ll x){ oi(x); oe(); }
inline void ode(ld x){ od(x); oe(); }
inline void ose(string x){ os(x); oe(); }
inline void maxin(ll &a, ll b){ a=max(a,b); }
inline void minin(ll &a, ll b){ a=min(a,b); }


int main(){
    ll N=ii(), M=ii();
    map<ll,set<ll>> e;
    REP(i,0,M){
        ll a=ii()-1;
        ll b=ii()-1;
        e[a].insert(b);
        e[b].insert(a);
    }
    ll ret=0;
    vector<bool> p(N,false);
    REP(i,0,N){
        if(p[i]==true){
            continue;
        }
        queue<ll> q;
        q.push(i);
        p[i]=true;
        ll t=0;
        while(!q.empty()){
            ll v=q.front();q.pop();
            t++;
            for(ll vv:e[v]){
                if(p[vv]==false){
                    p[vv]=true;
                    q.push(vv);
                }
            }
        }
        maxin(ret,t);
    }
    oie(ret);

    return 0;
}

Measured memory_bytes: 41632
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
#define rep(i,a,b) for(int i=a;i<(b);++i)
template<class T> inline bool chmin(T &a, T b){ if(a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){ if(a < b) { a = b; return true;} return false;}
typedef long long ll;
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;


int N,M,K;
int main() {
    cin >> N;
    vector<pair<string,pair<int,int> > > p;
    REP(i,N){
        string s;
        int sc;
        cin >> s >> sc;
        p.push_back(make_pair(s,make_pair(-sc,i)));
    }
    sort(p.begin(),p.end());
    REP(i,p.size()){
        cout << p[i].second.second + 1 << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V)) //小さい方からソート
#define REV(V) reverse(ALL(V)) //リバース
#define RSORT(V) SORT(V);REV(V) //大きい方からソート
#define NPN(V) next_permutation(ALL(V)) //順列
#define pb(n) push_back(n)
#define endl '\n'
#define Endl '\n'
#define DUMP(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define yes(n) cout << ((n) ? "yes" : "no"  ) << endl
#define Yay(n) cout << ((n) ? "Yay!": ":(") << endl
#define RAPID cin.tie(0);ios::sync_with_stdio(false)
#define VSUM(V) accumulate(ALL(V), 0)
#define MID(a,b,c) (a) < (b) && (b) < (c)
#define MIDe(a,b,c) (a) <= (b) && (b) <= (c)
#define IN(n) cin >> n
#define IN2(a,b) cin >> a >> b
#define IN3(a,b,c) cin >> a >> b >> c 
#define IN4(a,b,c,d) cin >> a >> b >> c >> d
#define VIN(V) for(int i = 0; i < (V).size(); i++) {cin >> (V).at(i);}
#define OUT(n) cout << n << endl
#define VOUT(V) REP(i, (V).size()) {cout << (V)[i] << endl;}
#define VOUT2(V) REP(i, (V).size()) {cout << (V)[i] << " ";} cout<<endl;
#define FIX cout << fixed << setprecision(15)

// 型マクロ定義
#define int long long
#define P pair<ll,ll>
#define Vi vector<ll>
#define VVi vector<vector<ll>>
#define Vd vector<double>
#define Vb vector<bool>
#define Vs vector<string>
#define Vc vector<char>
#define M map<ll,ll>
#define S set<ll>
#define PQ priority_queue<ll>
#define PQG priority_queue<ll,V,greater<ll>
//

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

using ll = long long;
using Graph = vector<vector<int>>;

const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int gcd(int a,int b){return b != 0 ? gcd(b, a % b) : a;} //最大公約数
int lcm(int a, int b){return a * b / gcd(a, b);}
string toStrUp(string str){char diff = 'A'-'a';REP(i,str.size()) str[i] += diff;return str;}
string gCh(string str, int key){return str.substr(key,1);}

signed main() {
  RAPID;
  // デフォルト変数定義
  int n=0,m=0,a=0,b=0,c=0,d=0,x=0,y=0,z=0;
  string s="",t="";
  //

  // ここから
  IN2(n,m);
  OUT(abs(n*m-n*2-m*2+4));
}

Measured memory_bytes: 256
#include<cstdio>

using namespace std;

const int P = 998244353;
typedef long long ll;
ll a[600000],n,k,ans;
 
ll pow_(ll x,ll y){
    ll rt = 1;
    for(; y; y >>= 1, x = x * x % P)
    	if(y & 1) rt = rt * x % P;
    return rt;
}
 
int main() {
    int i;
	scanf("%d%d", &k, &n);
	a[0] = 1; ans = pow_(2, n-1);
    for(i = 1; i <= n; ++i)
		a[i] = a[i-1] * (n-i+1) % P * pow_(i,P-2) % P;
    for(i = k&1; i < k; i += 2) ans = (ans-a[i]+P) % P;
    printf("%lld\n", ans);
}

Measured memory_bytes: 4224
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
#include <string.h>
#include <ctype.h>
using namespace std;
 
int main(){
    
    int H,W,y=0,x=0;
    char A[100][100]={},B[100][100]={},C[100][100];
    bool f=0;

    cin >> H >>W;

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

    for(int i=0;i<H;i++){
        f=0;
        for(int j=0;j<W;j++){
            if(A[i][j]=='#'){
                f=1;
                
            }
        }
        if(f==1){
            for(int k=0;k<W;k++){
                B[y][k]=A[i][k];
            }
            y+=1;
        }
    }


    for(int i=0;i<W;i++){
        f=0;
        for(int j=0;j<y;j++){
            if(B[j][i]=='#'){
                f=1;
            }
        }

        if(f==1){
            for(int k=0;k<y;k++){
                C[k][x]=B[k][i];
            }
            x+=1;
        }
    }


    for(int i=0;i<y;i++){
        for(int j=0;j<x;j++){
            cout << C[i][j];
        }
        cout <<endl;
    }



    return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int main() {
    ll N, W;
    cin >> N >> W;
    vector<ll> v(N), w(N);
    rep(i, N) cin >> v[i] >> w[i];
    ll dp[110][11000];
    memset(dp, 0, sizeof(dp));
    rep(i, N) rep(j, W+1) {
        if(j - w[i] >= 0) chmax(dp[i+1][j], dp[i][j-w[i]] + v[i]);
        chmax(dp[i+1][j], dp[i][j]);
    }
    cout << dp[N][W] << endl;
}



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

int main() {
    int n;
    cin >> n;
    while(n > 0) {
        int r = n % 10;
        if(r == 7){
            puts("Yes");
            return 0;
        }
        n /= 10;
    }
    puts("No");
}

Measured memory_bytes: 3604
import Control.Applicative

myProd :: Integer -> Integer -> Integer
myProd _ 0 = 0
myProd 0 _ = 0
myProd _ (-1) = -1
myProd x y
    | y > 10 ^ 18 = -1
    | otherwise   = x * y

solve :: [Integer] -> Integer
solve xs = foldr1 myProd (1:xs)

main :: IO ()
main = do
    getLine
    print =<< solve . map read . words <$> getLine


Measured memory_bytes: 187372
from sys import stdin

N = int(stdin.readline().rstrip())
tasks = []
ans = 'Yes'

for i in range(N):
    t, d = (int(x) for x in stdin.readline().rstrip().split())
    tasks.append((t, d))

tasks = sorted(tasks, key=lambda x: x[1])

total = 0
for x, y in tasks:
    total += x
    if total > y:
        ans = 'No'

print(ans)

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


int main(void)
{
	//変数の宣言
	int n,z,w;
	int a[2010];
	int big[2010];
	int small[2010];
	
	//よく使う変数
	int i,j,k,l;
	int flag=0;
	int ans=0;
	int count=0;
	int temp,temp1,temp2;
	//データの読み込み
	scanf("%d %d %d",&n,&z,&w);
	
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	
//	printf("nは%dです\n", n);
//	printf("データの読み込み終了\n");
	//実際の処理
	
	for(i=1;i<n;i++){
		big[i]=abs(a[n-1-i]-a[n-1]);
		for(j=1;j<i;j++){
			if(big[i]<small[j]) big[i]=small[j];
		}
		small[i]=abs(a[n-1-i]-a[n-1]);
		for(j=1;j<i;j++){
			if(small[i]>big[j]) small[i]=big[j];
		}
	}
	
	ans=abs(w-a[n-1]);
	for(i=1;i<n;i++){
		if(ans<small[i]) ans=small[i];
	}
	
//	for(i=1;i<n;i++){
//		printf("big[%d]=%d,small[%d]=%d\n",i,big[i],i,small[i]);
//	}
	
//	printf("計算部分終了\n");
	//出力
	
	printf("%d",ans);
	
//	printf("結果の出力終了\n");
	
	return 0;
	
}



Measured memory_bytes: 128
#include "iostream"
#include "algorithm"
#include "string"
#include "vector"
#include "cmath"
#include "bitset"
#define lp(n) for (int i = 0; i < n; i++)
#define lop(n,i) for (int i = 0; i < n; i++)
#define mod 1000000007
#define ll long long int
#define sp ' '
#define intmax 2147483647
#define intmin –2147483648
#define llmax 9223372036854775807
#define llmin -9223372036854775808
using namespace std;

int n, a[200000];

int main(){
	cin >> n;
	lp(n)
		cin >> a[i];
	for (int i = n - 1; i >= 0; i -= 2)
		cout << a[i] << sp;
	for (int i = (n % 2 == 0 ? 0 : 1); i < n - 1; i += 2)
		cout << a[i] << sp;
	return 0;
}

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

int main() {
	// your code goes here
	int n,k;
	cin>>n>>k;
	int A[n] = {0};
	for(int i=0;i<k;i++){
	    int d;
	    cin>>d;
	    for(int j=0;j<d;j++){
	        int a;
	        cin>>a;
	        A[a-1] = 1;
	    }
	}
	int cnt = 0;
	for(int i=0;i<n;i++){
	    if(A[i]==0) cnt++;
	}
	cout<<cnt<<endl;
	return 0;
}


Measured memory_bytes: 3676
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_macros)]
#![allow(unused_imports)]

use std::str::FromStr;
use std::io::*;
use std::collections::*;
use std::cmp::*;

struct Scanner<I: Iterator<Item = char>> {
    iter: std::iter::Peekable<I>,
}

macro_rules! exit {
    () => {{
        exit!(0)
    }};
    ($code:expr) => {{
        if cfg!(local) {
            writeln!(std::io::stderr(), "===== Terminated =====")
                .expect("failed printing to stderr");
        }
        std::process::exit($code);
    }}
}

impl<I: Iterator<Item = char>> Scanner<I> {
    pub fn new(iter: I) -> Scanner<I> {
        Scanner {
            iter: iter.peekable(),
        }
    }

    pub fn safe_get_token(&mut self) -> Option<String> {
        let token = self.iter
            .by_ref()
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            Some(token)
        }
    }

    pub fn token(&mut self) -> String {
        self.safe_get_token().unwrap_or_else(|| exit!())
    }

    pub fn get<T: FromStr>(&mut self) -> T {
        self.token().parse::<T>().unwrap_or_else(|_| exit!())
    }

    pub fn vec<T: FromStr>(&mut self, len: usize) -> Vec<T> {
        (0..len).map(|_| self.get()).collect()
    }

    pub fn mat<T: FromStr>(&mut self, row: usize, col: usize) -> Vec<Vec<T>> {
        (0..row).map(|_| self.vec(col)).collect()
    }

    pub fn char(&mut self) -> char {
        self.iter.next().unwrap_or_else(|| exit!())
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.get::<String>().chars().collect()
    }

    pub fn mat_chars(&mut self, row: usize) -> Vec<Vec<char>> {
        (0..row).map(|_| self.chars()).collect()
    }

    pub fn line(&mut self) -> String {
        if self.peek().is_some() {
            self.iter
                .by_ref()
                .take_while(|&c| !(c == '\n' || c == '\r'))
                .collect::<String>()
        } else {
            exit!();
        }
    }

    pub fn peek(&mut self) -> Option<&char> {
        self.iter.peek()
    }
}

const INF: usize = 1 << 60;

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin.bytes().map(|c| c.unwrap() as char));
    let N: usize = sc.get();
    let A: Vec<usize> = sc.vec(N);
    let mut ans = INF;
    for i in 0..N {
        let mut rem = A[i];
        let mut cnt = 0;
        while rem % 2 == 0 {
            cnt += 1;
            rem /= 2;
        }
        ans = min(ans, cnt);
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352