akhauriyash/Code-Regression huggingface dataset:
n, k = gets.split.map(&:to_i)
n -= 2

ans = 0
(1..11).each do |i|
    num = (n+10)/11
    n -= 1

    (1..5).each do |j|
        a = 7*i+j-7
        result = 72 + 9*a
        ans += num if result%11 == k
    end
end
puts ans

Measured memory_bytes: 1788
//package AtCoder_163;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args)throws IOException {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        double pi=3.141592653589793;
        int r=Integer.parseInt(br.readLine());
//        System.out.println(Math.PI);
        System.out.println(2*pi*r);
    }
}


Measured memory_bytes: 33364
#include <stdio.h>
int main(void)
{
  int a[1000][1000]={0};
  int b[1000]={0};
  int out[1000]={0};
  int n,m;
  int i,j;

  scanf("%d",&n);
  scanf("%d",&m);
  for (i=0; i<n; i++) {
	for (j=0; j<m; j++) {
	  scanf("%d",&a[i][j]);
	}
  }

  for (i=0; i<m; i++) {
	scanf("%d",&b[i]);
  }

  for (i=0; i<n; i++) {
	for (j=0; j<m; j++) {
	  out[i]+=a[i][j]*b[j];
	}
  }

  for (i=0; i<n; i++) {
	printf("%d\n",out[i]);
  }
  return 0;
}

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))

using namespace std;

using i32 = int;
using i64 = long long;
using u64 = unsigned long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vu64 = vector<u64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
inline u64 xorshift() { static u64 x = 88172645463325252ull; x = x ^ (x << 7); return x = x ^ (x >> 9); }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T power(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
template <typename T, typename S> istream& operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
template <typename T, typename S> ostream& operator<<(ostream &os, pair<T, S> &p) { os << p.first << ' ' << p.second; return os; }

void solve() {
  int n; cin >> n;
  while (n--) {
    vector<pair<f80, f80>> xy(4);
    rep(i, 4) cin >> xy[i];
    f80 k0 = (xy[1].second - xy[0].second) / (xy[1].first - xy[0].first);
    f80 k1 = (xy[3].second - xy[2].second) / (xy[3].first - xy[2].first);
    if (k0 == k1) {
      cout << "YES" << '\n';
    } else {
      cout << "NO" << '\n';
    }
  }
}



Measured memory_bytes: 3276
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_int.hpp>
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E17;

#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
///////////////////////////////////////

ll num(string s){
    ll res=0;
    rep(i,0,s.size()-1){
        res*=10;
        res+=(s[i]-'0');
    }
    return res;
}

int main(){fastio
    
    string s;
    
    stack<ll>que;
    while(cin>>s){
        ll a,b;
        
        if(s[0]=='+'){
            a=que.top();que.pop();
            b=que.top();que.pop();
            que.push(a+b);
        }else if(s[0]=='-'){
            a=que.top();que.pop();
            b=que.top();que.pop();
            que.push(b-a);
        }else if(s[0]=='*'){
            a=que.top();que.pop();
            b=que.top();que.pop();
            que.push(a*b);
        }else{
            que.push(num(s));
        }
    }
    cout<<que.top()<<endl;
    
    return 0;
}






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

int main(){
	int h,w;
	cin>>h>>w;
	char s[52][52];
	int a[]={-1,0,1};
	for(int i=0;i<w;i++){
		s[0][i]='.';
	}
	for(int i=1;i<=h;i++){
		s[i][0]='.';
		for(int j=1;j<=w;j++){
			cin>>s[i][j];
		}
		s[i][w+1]='.';
	}
	for(int i=0;i<w+2;i++){
		s[h+1][i]='.';
	}
	int sum=0;
	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++){
			for(int k=0;k<3;k++){
				for(int l=0;l<3;l++){
					if(s[i][j]=='#'){
						cout<<'#';
						goto age;
					}
					if(s[i+a[k]][j+a[l]]=='#'){
						sum++;
					}
				}
			}
			cout<<sum;
			age:;
			sum=0;
		}
		cout<<endl;
	}
}


Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.* ;
 
class Main{
  public static void main(String[] args)throws IOException{
      
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str = br.readLine();
  
    String[] strAry = str.split(" ");
    int W = Integer.parseInt(strAry[0]);
  	int H = Integer.parseInt(strAry[1]);
  	int x = Integer.parseInt(strAry[2]);
  	int y = Integer.parseInt(strAry[3]);
  	int r = Integer.parseInt(strAry[4]);
  	

  	if ( ( W-( x+r) ) >= 0 && ( H- ( y+r) >=0  ) &&(x-r)>=0 &&(y-r)>=0  )  {
  		System.out.println( "Yes" );
  	}
  	else { System.out.println( "No");
  	}	
  		
  	}
  }

Measured memory_bytes: 24388
#include <bits/stdc++.h>
#define SZ(x) ((int) (x).size())
using namespace std;

typedef long long i64;

vector<int> mul(const vector<int>& a, const vector<int>& b) {
    int n = SZ(a);
    vector<int> c(n);
    for (int i = 0; i < n; ++i) {
        c[i] = b[a[i]];
    }
    return c;
}

vector<int> Pow(vector<int> x, int64_t y) {
    int n = SZ(x);
    vector<int> ret(n);
    for (int i = 0; i < n; ++i) {
        ret[i] = i;
    }
    for (; y > 0; y /= 2) {
        if (y & 1) {
            ret = mul(ret, x);
        }
        x = mul(x, x);
    }
    return ret;
}

int main() {
    #ifdef LOCAL_RUN
    freopen("task.in", "r", stdin);
    freopen("task.out", "w", stdout);
    //freopen("task.err", "w", stderr);
    #endif // ONLINE_JUDGE
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n;
    cin >> n;

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

    vector<int> perm(n - 1);
    for (int i = 0; i < n - 1; ++i) {
        perm[i] = i;
    }

    int m;
    int64_t k;
    cin >> m >> k;
    
    while (m-- > 0) {
        int x;
        cin >> x;
        swap(perm[x - 2], perm[x - 1]);
    }
    perm = Pow(perm, k);

    vector<int> fdist(n - 1);
    for (int i = 0; i < n - 1; ++i) {
        fdist[i] = dists[perm[i]];
    }

    vector<int64_t> fans(n);
    fans[0] = A[0];
    for (int i = 1; i < n; ++i) {
        fans[i] = fans[i - 1] + fdist[i - 1];
    }

    for (int i = 0; i < n; ++i) {
        cout << fans[i] << '\n';
    }
}

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

long long k, sum = 0;

int main() {
  cin >> k;
  for (int i = 1; i <= k; ++i)
    for (int j = 1; j <= k; ++j)
      for (int l = 1; l <= k; ++l) sum += gcd(i, gcd(j, l));
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
typedef long long LL;
#define SORT(c) sort((c).begin(),(c).end())

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

using namespace std;
int main(void)
{
  string s,p;
  cin >> s >> p;
  s+=s;
  REP(i,s.size()-p.size())
    if(string(s.begin()+i,s.begin()+i+p.size())==p){
      cout << "Yes" << endl;
      return 0;
    }
  cout << "No" << endl;
  return 0;
      





}

Measured memory_bytes: 3196
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<bitset>
#define maxn 100005
#define mid ((nl+nr)>>1)
using namespace std;
typedef long long ll;
int n,m;
int fa[maxn];
int getfa(int now)
{
	return fa[now]==now ? now : fa[now]=getfa(fa[now]);
}
int vis[maxn];
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
	fa[i]=i;
	for(int i=1;i<=m;i++)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		int xx=getfa(x),yy=getfa(y);
		if(xx!=yy)
		{
			fa[xx]=yy;
		}
	}
	int ans=-1;
	for(int i=1;i<=n;i++)
	{
		int xx=getfa(i);
		if(!vis[xx]) vis[xx]=1,ans++;
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 4600
#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using Graph= vector<vector<ll>>; 
#define rep(i,n) for (ll i=0; i < (n); ++i)
#define rep2(i,n,m) for(ll i=n;i<=m;i++)
#define rep3(i,n,m) for(ll i=n;i>=m;i--)
#define pb push_back
#define eb emplace_back
#define ppb pop_back
#define mpa make_pair
#define fi first 
#define se second 
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}
 
//隣のきゃくは客はようよく柿食う客だ
//垢巻紙赤巻紙青牧蒼秋神青巻紙木巻紙黄巻紙 
int main(){
 ll n,m ;
 cin>> n>>m ;
 vector<P> A(n) ;
 rep(i,n) cin>> A[i].first>>A[i].second ;
 sort(A.begin(),A.end()) ;
 //後ろから見るm日目から
 priority_queue<ll> q ;
 ll ans=0 ;
 ll x=0 ;
 rep(i,m+1){
  
   while(x<=n-1&&A[x].first<=i){
     q.push(A[x].se) ;
     x++ ;
   }
   if(!q.empty()){
     ans+= q.top() ;
     q.pop() ;
   } 
 }
  cout<<ans<<endl ;
  return 0;
  }

Measured memory_bytes: 2936
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <vector>

using namespace std;

typedef long long int64;
constexpr int p = 1e9+7;
constexpr long long M = 0x777777777777777777777777777777777777777LL;

int N;
vector<int> edge[100008];

pair<int, int> solve(int i=0, int parent=-1) {
    pair<int, int> ret(1, 1);
    for(int e : edge[i]) if(e!=parent) {
        pair<int, int> result = solve(e, i);
        int b = result.first;
        int w = b + result.second;
        if(p<=w) w-=p;
        ret.first = (int)(((int64)ret.first * w) % p);
        ret.second = (int)(((int64)ret.second * b) % p);
    }
    return ret;
}

int main() {
	scanf("%d", &N);
    for(int n=1; n<N; ++n) {
        int x, y;
        scanf("%d%d", &x, &y);
        --x, --y;
        edge[x].emplace_back(y);
        edge[y].emplace_back(x);
    }
    pair<int, int> result = solve();
    printf("%d\n", (result.first + result.second)%p);
	return 0;
}


Measured memory_bytes: 12672
#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <stdio.h>
#include <vector>

using namespace std;
typedef long long ll;

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

ll modpow(ll a,ll n,ll m) {
    if(n==1) return a%m;
    if(n%2==1) return (a*modpow(a,n-1,m))%m;
    ll b = modpow(a,n/2,m)%m;
    return (b*b)%m;
}

int main() {

    ll mod = 2019;
    string S;
    cin >> S;
    ll N = S.length();
    ll A[N];
    rep(i,N){
        if(i==0) A[N-1] = S[N-1]-48;
        else A[N-1-i] = ((ll(S[N-1-i])-48)*modpow(10,i,mod))%mod;
    }
    ll B[N];
    rep(i,N){
        if(i==0) B[N-1] = ll(S[N-1])-48;
        else B[N-1-i] = (B[N-i]+A[N-1-i])%mod;
    }
    sort(B,B+N);
    ll out = 0;
    ll cnt = 0;
    rep(i,N-1){
        if(B[i]==0) out++;
        if(B[i]==B[i+1]) cnt++;
        else if(cnt>0){
            out += cnt*(cnt+1)/2;
            cnt = 0;
        }
        if(i==N-2&&cnt>0) out += cnt*(cnt+1)/2;
    }
    cout << out << endl;
    return 0;
}

Measured memory_bytes: 6884
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <utility>
#include <set>
#include <vector>
#include <functional>
#include <map>
#include <queue>
using namespace std;
int main()
{
  string s;
  cin>>s;
  for (int i=0;i<s.size();i++)
  {
    if (i%2==0) cout<<s[i];
  }
  cout<<endl; 
  //system("pause");
  return 0;
}

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

int main() {
    int N;
    cin >> N;
    int ans, cnt;
    char s;
    for (int i = 0; i < N; i++){
        cin >> s;
        if (s == 'I'){
            cnt++;
        }
        else {
            cnt--;
        }
        ans = max(ans, cnt);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<array>
using namespace std;
array<int,100005>dp;
int a[100005];
void memo(int i,int n,int k)
{
	if(i>n) return;
	for(int j=1;j<=k;j++)
	{
		dp[i+j] = min(dp[i+j],dp[i]+abs(a[i+j]-a[i]));
	}
	memo(i+1,n,k);
}
int main()
{
	int n,k;cin>>n>>k;
	for(int i=1;i<=n;i++) cin>>a[i];
	dp.fill(INT_MAX);
    dp[1] = 0;
    memo(1,n,k);
    cout<<dp[n]<<endl;
    return 0;
}

Measured memory_bytes: 1024
l,r = map(int,input().split())

if r - l >= 2018:
    print(0)
    exit()
else:
    l1 = l % 2019
    r1 = r % 2019
    ans = 10**10
    if r1 < l1:
        r1 += 2019
    for i in range(l1,r1+1):
        for j in range(i+1,r1+1):
            ans = min(ans,(i*j)%2019)

print(ans)


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

using namespace std;

int main(void) {
    int N, K;
    cin >> N >> K;
    string D;
    for(int i=0; i<K; i++) {
        char c;
        cin >> c;
        D.push_back(c);
    }

    for(int i=N; i<1000000; i++) {
        if(to_string(i).find_first_of(D) == string::npos) {
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}


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

// ABC060B Choose Integers

int main() {
    int A, B, C;
    cin >> A >> B >> C;
    int D;
    D = A % B;
    while (D != C){
        D = (D + A) % B;
        if (D == A % B){
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int maxn = 500500;
using ii = pair<int,int>;
ii tr[maxn + maxn];
int n;
void upd(int p, int v){
	for(tr[p += n] = {v, p}; p > 1; p >>= 1)
		tr[p>>1] = max(tr[p], tr[p^1]);
}
ii qry(int l, int r){
	ii mx = {-1, -1};
	for(l += n, r += n; l < r; l >>= 1, r >>= 1){
		if(l&1) mx = max(mx, tr[l++]);
		if(r&1) mx = max(mx, tr[--r]);
	}
	return mx;
}
int ans[maxn], val[maxn], cval[maxn];;
int main(){
	int k; cin >> n >> k;
	for(int i = n + n; i >= 1; i--) tr[i] = {-1, -1};
	for(int i = 0; i < n; i++){
		int x; cin >> x; x--;
		val[i] = cval[i] = x;
		upd(i, x);
	}
	set<int> do_it;
	auto is_max = [&](int p){
		int l = max(p - k + 1, 0);
		int r = min(p + k, n);
		if(p == qry(l, r).second && val[p] >= 0){
			return true;
		}
		return false;
	};
	auto push_block = [&](int pw){
		if(pw < 0) return;
		if(pw * k >= n) return;
		int l = pw * k;
		int r = min(l + k, n);
		int p = qry(l, r).second;
		if(is_max(p)){
			do_it.insert(p);
		}
	};
	for(int i = 0; i < n; i += k){
		push_block(i / k);
	}
	for(int i = n; i >= 1; i--){
		if(do_it.empty()) break;
		int pick = *prev(do_it.end()); do_it.erase(prev(do_it.end()));
		upd(pick, -1); val[pick] = -1;
		int blk = pick / k;
		ans[pick + 1] = i;
		push_block(blk - 1);
		push_block(blk);
		push_block(blk + 1);
	}
	for(int i = 1; i <= n; i++)
		cout << ans[i] << "\n";
	return 0;
}


Measured memory_bytes: 40704
#include <bits/stdc++.h> 
using namespace std; 
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define flash ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define debug(x) cerr << " - " << #x << ": " << x << endl;
#define debugs(x, y) cerr << " - " << #x << ": " << x << " " << #y << ": " << y << endl;
#define all(x) (x).begin(),(x).end()
#define sz(x) (ll)x.size()
#define ll long long
#define INF 1000000000
#define MOD 1000000007
#define pb push_back
#define ve vector<ll>
#define dos pair<ll,ll>
#define vedos vector<dos>
#define rand mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define EPS 0.000001
struct greateri
{
    template<class T>
    bool operator()(T const &a, T const &b) const { return a > b; }
};
void setIO(string s) {
  ios_base::sync_with_stdio(0); cin.tie(0); 
  freopen((s+".in").c_str(),"r",stdin);
  freopen((s+".out").c_str(),"w",stdout);
}
map<string,int>g;
int main()
{
  //flash;
  int n;
  cin>>n;
  for (int i = 0; i < n; ++i)
  {
    string nal;
    cin>>nal;
    g[nal]++;
  }
  cout<<g.size();
  return 0;
}
//code the AC sol !
// BS/queue/map

Measured memory_bytes: 19228
#include <algorithm>
#include <bits/stdc++.h>
#include <cstddef>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/z_algorithm.hpp
#ifndef Z_ALGORITHM_HPP
#define Z_ALGORITHM_HPP


/*
usage:

std::string S = "momomosumomomosu";
std::vector<std::size_t> Z = tools::z_algorithm(S.begin(), S.end());
std::cout << Z[0] << ' ' << Z[1] << ' ' << Z[2] << ' ' << Z[3] << std::endl; //=> 16 0 4 0
*/

// Source: 【図解】線形時間の文字列アルゴリズム「Z algorithm」をイラストとアニメーションでかみ砕く - Qiita ( https://qiita.com/Pro_ktmr/items/16904c9570aa0953bf05 )
// Author: Pro_ktmr ( https://qiita.com/Pro_ktmr )
// License: Unknown
namespace tools {
  template <typename InputIter>
  ::std::vector<::std::size_t> z_algorithm(const InputIter& begin, const InputIter& end) {
    ::std::vector<typename ::std::iterator_traits<InputIter>::value_type> S(begin, end);
    ::std::vector<::std::size_t> Z(S.size());

    // Z[0] は自明
    Z[0] = S.size();

    ::std::size_t i = 1;
    ::std::size_t prefix = 0;
    while (i < S.size()) {

      // ナイーブに、 prefix をできるだけ伸ばす
      for (; i + prefix < S.size() && S[prefix] == S[i + prefix]; ++prefix);

      // Z[i] は確定
      Z[i] = prefix;

      // prefix が 0 ならもう得られる情報は無い
      // ナイーブに次の探索へ
      if (prefix == 0) {
        ++i;
        continue;
      }

      // Z[i + 1] ～ Z[i + prefix - 1] について、既存の情報の使い回しができないか考える
      ::std::size_t extra_offset = 1;
      for (; extra_offset < prefix && extra_offset + Z[extra_offset] < prefix; ++extra_offset) {

        // これは完全に使い回せる
        Z[i + extra_offset] = Z[extra_offset];
      }

      // extra_offset + Z[extra_offset] < prefix を満たさない Z[i + extra_offset] は一部だけ使い回せる
      // i を i + extra_offset へ進めて次の探索へ
      i += extra_offset;

      // 一部使い回し分
      prefix -= extra_offset;
    }

    return Z;
  }
}

#endif

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef ::std::int_fast64_t i64;
typedef ::std::uint_fast64_t u64;
typedef ::std::int_fast32_t i32;
typedef ::std::uint_fast32_t u32;

namespace tools {
  template <typename T>
  void read(::std::istream& is, ::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    vector.reserve(size);
    ::std::copy_n(::std::istream_iterator<T>(is), size, ::std::back_inserter(vector));
  }
  template <typename T>
  void read(::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    ::tools::read(::std::cin, vector, size);
  }

  template <typename T, ::std::size_t N>
  void read(::std::istream& is, ::std::array<T, N>& array) {
    ::std::copy_n(std::istream_iterator<T>(is), N, array.begin());
  }
  template <typename T, ::std::size_t N>
  void read(::std::array<T, N>& array) {
    ::tools::read(::std::cin, array);
  }
}

#endif

// main.cpp

int main() {
  i64 N;
  std::string S;
  std::cin >> N >> S;

  i64 answer = 0;
  for (auto it = S.begin(); it != S.end(); ++it) {
    std::vector<std::size_t> Z = tools::z_algorithm(it, S.end());
    for (std::size_t i = 0; i < Z.size(); ++i) {
      if (Z[i] <= i) {
        answer = std::max<i64>(answer, Z[i]);
      }
    }
  }

  std::cout << answer << std::endl;
  return 0;
}

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

int main() {
    string s;
    cin >> s;
    int len = (int)s.size();
    bool ok = true;
    for (int i = 0; i < len - 1; i++) {
        if (s.at(i) != s.at(i + 1)) ok = false;
    }
    if (ok) {
        cout << 0 << endl;
        return 0;
    }

    int minimum = 100;
    for (char c = 'a'; c <= 'z'; c++) {
        string t = s;
        for (int l = 0; l <= len - 1; l++) {
            bool is_all_same = true;
            for (int i = 0; i < len - l - 1; i++) {
                if (t.at(i) == c || t.at(i + 1) == c) t.at(i) = c;
                else is_all_same = false;
            }
            
            if (is_all_same) {
                minimum = min(minimum, l + 1);
                break;
            }
        }
    }

    cout << minimum << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <valarray>
#include <map>
#include <set>
#include <list>
#include <queue>
#include <stack>
#include <bitset>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <complex>
#include <string>
#include <sstream>

#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cmath>

using namespace std;

#define all(c) c.begin(),c.end()
#define repeat(i,n) for(int i=0;i<static_cast<int>(n);i++)
#define debug(x) #x << "=" << (x)
#define dump(x) cerr << debug(x) << " (L:" << __LINE__ << ")"<< endl

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<long> vl;
typedef vector<vector<long> > vvl;
typedef vector<string> vs;

template<typename T>
ostream& operator<<(ostream& os, const vector<T>& vec){
    os << "[";
    for(int i = 0; i < vec.size(); i++){
        os << vec[i] << ",";
    }
    os << "]";
    return os;
}

template<typename T>
T input(){
    T t;
    cin >> t;
    return t;
}

template<typename T>
vector<T> input(const int N){
    vector<T> v(N);
    repeat(i,N) cin >> v[i];
    return v;
}

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

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

long long mul(const long long& a, const long long& b, const long long& mod) {
    return ((a % mod) * (b % mod)) % mod;
}

long long power(const long long& x, const long long& y, const long long& mod) {
    if (y == 0) {
        return 1;
    } else if (y == 1) {
        return x % mod;
    } else {
        long long value = power(x, y / 2, mod);
        if (y % 2 == 0) {
            return mul(value, value, mod);
        } else {
            return mul(value, value, mod) * x % mod;
        }
    }
}

long long div(const long long& a, const long long& b, const long long& mod) {
    return mul(a, power(b, mod - 2, mod), mod);
}

map<long long, long long> factorials;
long long factorial(const long long& n, const long long& mod) {
    if (n == 0 || n == 1) {
        return 1;
    }
    if (factorials[n] != 0) {
        return factorials[n];
    }
    factorials[n] = n * factorial(n - 1, mod) % mod;
    return factorials[n] % mod;
}

long long combination(const long long& n, const long long& x, const long long& mod) {
    long long numerator = 1;
    long long denominator = 1;
    repeat(i, x) {
        numerator *= (n - i) % mod;
        numerator %= mod;
        denominator *= (i + 1) % mod;
        denominator %= mod;
    }
    return div(numerator, denominator, mod);
}

int main(){
    int N;
    cin >> N;
    char color;
    while (cin >> color) {
        if (color == 'Y') {
            cout << "Four" << endl;
            return 0;
        }
    }
    cout << "Three" << endl;
    return 0;
}


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

using namespace std;
typedef long long ll;
typedef long double ld;
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)


// Write From This Line
int main()
{
	int h, w;
	cin >> h >> w;
	vector<string> s(h);
	rep(i,h) cin >> s[i];
	vector<int> count(26,0);
	rep(i,h){
		rep(j,w){
			int c = s[i][j] - 'a';
			count[c] += 1;
		}
	}

	int need4, need2;
	need4 = (h / 2) * (w / 2) ;
	need2 = (h/2) * (w%2) + (w/2) * (h%2);

	rep(i,26){
		while(count[i] >= 4){
			if(need4 == 0) break;
			count[i] -= 4;
			need4 --;
		}
	}
	rep(i,26){
		while(count[i] >= 2){
			if(need2 == 0) break;
			count[i] -= 2;
			need2 --;
		}
	}
	if(need4 + need2){
		puts("No");
	} else {
		puts("Yes");
	}

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define N 100005
ll n, m, x, y, z, f[N], d[N], r[N], s;
bool ish(ll q)
{
	return q >= 0;
}
void go(ll w)
{
	ll q = w, e = f[q];
	while (e != f[e])
	{
		d[q] += d[e];
		f[q] = f[e];
		e = f[e];
	}
}
void merge()
{
	ll q = f[x], w = f[y], t = d[x] - d[y] + z;
	if (r[q] < r[w])
		swap(q, w), t = -t;
	f[w] = q;
	d[w] = t;
	r[q] += r[w];
}
int main()
{
	scanf("%lld%lld", &n, &m);
	for (int i = 1; i <= n; i++)
		f[i] = i, r[i] = 1;
	for (int i = 0; i < m; i++)
	{
		scanf("%lld%lld%lld", &x, &y, &z);
		go(x); go(y);
		/*for (int i = 1; i <= n; i++)
			cout << i << " " << d[i] << endl;*/
		if (f[x] == f[y])
		{
			if(d[y]-d[x]!=z)
			{
				cout << "No\n";
				return 0;
			}
		}
		else
			merge();
	}

	cout << "Yes\n";
	return 0;
}

Measured memory_bytes: 2560
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out);
        String[] arr = br.readLine().split(" ");
        long A = Long.parseLong(arr[0]);
        long B = Long.parseLong(arr[1]);

        int digit = 0;
        while (Math.pow(2, digit) < B) {
            digit++;
        }

        int[] arr2 = new int[digit + 1];

        calcXOR(arr2, A - 1, digit);
        calcXOR(arr2, B, digit);

        String binAns = "";
        for (int l : arr2) {
            binAns += l % 2 == 1 ? "1" : "0";
        }
        out.println(Long.parseLong(binAns, 2));
        out.close();
    }
    
    private static void calcXOR(int[] arr, long X, int digit) {
        String digitStr = "%" + String.valueOf(digit + 1) + "s";
        if (X % 2 == 0) {
            String bin = String.format(digitStr, Long.toBinaryString(X));
            String[] arr3 = bin.split("");
            for (int j = 0; j < digit + 1; j++) {
                arr[j] += arr3[j].equals("1") ? 1 : 0;
            }
            if (X / 2 % 2 == 1) {
                arr[digit] += 1;
            }
        } else {
            if ((X + 1) / 2 % 2 == 1) {
                arr[digit] += 1;
            }
        }
    }
}

Measured memory_bytes: 23124
def D_PreparingBoxes():
    N = int(input())
    a = list(map(int, input().split()))
    b = [0] * N
    for x in reversed(range(N)):
        if sum(b[x::x+1]) % 2 != a[x]:
            b[x] = 1
    print(sum(b))
    for x in range(N):
        if b[x]:
            print(x+1, end=" ")

if __name__ == "__main__":
    D_PreparingBoxes()

Measured memory_bytes: 8384
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define ALL(x) (x).begin(), (x).end()
#define REP(i ,n) for(int i = 0; i < (int)(n); i++)
#define pb push_back
typedef vector<int>vint;
typedef vector<ll>vll;
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}
int main()
{
    int N,M;
    cin >> N >> M;
    vll A(N);
    vector<pair<ll,ll>> B;
    cin >> A;
    REP(i,M){
        int b,c;
        cin >> b >> c;
        B.pb({c,b});
    }
    for(auto a : A){
        B.pb({a,1});
    }
    sort(B.begin(),B.end(),greater<pair<ll,ll>>());
    ll ans = 0;
    ll cnt = N;
    for(auto b : B){
        if(cnt > b.second){
            ans += b.first*b.second;
            cnt -= b.second;
        }else{
            ans += b.first*cnt;
            break;
        }
    }
    cout << ans << endl;

}

Measured memory_bytes: 7152
#include<bits/stdc++.h>
#define me(a,x) memset(a,x,sizeof(a))
#define sc scanf
#define itn int
using namespace std;
const int N=1e6;
const long long mod=1e9+7;
const int oo=0x7fffffff;
const int sup=0x80000000;
typedef long long ll;
typedef unsigned long long ull;
template <typename it>void db(it *begin,it *end){while(begin!=end)cout<<(*begin++)<<" ";puts("");}
template <typename it>
string to_str(it n){string s="";while(n)s+=n%10+'0',n/=10;reverse(s.begin(),s.end());return s;}
template <typename it>int o(it a){cout<<a<<endl;return 0;}
ll mul(ll a,ll b,ll c){ll ans=0;for(;b;b>>=1,a=(a+a)%c)if(b&1)ans=(ans+a)%c;return ans;}
ll ksm(ll a,ll b,ll c){ll ans=1;for(;b;b>>=1,a=mul(a,a,c))if(b&1)ans=mul(ans,a,c);return ans;}
int n;
int a[N];
int main(){
	//freopen("in.txt","r",stdin);
	cin>>n;
	ll ans=0;
	for(int i=1;i<=n;i++)cin>>a[i],ans^=a[i];
	if(ans==0)o("Yes");
	else o("No");
}


Measured memory_bytes: 640
package main

import (
	"fmt"
)

const MOD = 1000000007

func ModAdd(a, b int64) int64 {
	return (a + b) % MOD
}

func ModMul(a, b int64) int64 {
	return a * b % MOD
}

func ModSub(a, b int64) int64 {
	r := (a%MOD - b%MOD) % MOD
	if r < 0 {
		r += MOD
	}
	return r
}

func ModDiv(a, b int64) int64 {
	return a % MOD * ModInv(b) % MOD
}

func ModPow(a, n int64) int64 {
	var r int64 = 1
	for n > 0 {
		if n&1 == 1 {
			r = r * a % MOD
		}
		a = a * a % MOD
		n >>= 1
	}
	return r
}

func ModInv(a int64) int64 {
	var b, u, v int64 = MOD, 1, 0
	for b > 0 {
		t := a / b
		a -= t * b
		a, b = b, a
		u -= t * v
		u, v = v, u
	}
	u %= MOD
	if u < 0 {
		u += MOD
	}
	return u
}

type Q struct {
	idx, value int
	a, b       int
	index      int
}

type QS []*Q

func (p QS) Len() int           { return len(p) }
func (p QS) Less(i, j int) bool { return p[i].value > p[j].value }
func (pq QS) Swap(i, j int) {
	pq[i], pq[j] = pq[j], pq[i]
	pq[i].index = i
	pq[j].index = j
}

func (pq *QS) Push(x interface{}) {
	n := len(*pq)
	item := x.(*Q)
	item.index = n
	*pq = append(*pq, item)
}

func (pq *QS) Pop() interface{} {
	old := *pq
	n := len(old)
	item := old[n-1]
	old[n-1] = nil  // avoid memory leak
	item.index = -1 // for safety
	*pq = old[0 : n-1]
	return item
}

func main() {
	var N int
	fmt.Scanf("%d\n", &N)
	A := make([]int, N+1)
	B := make([]int, N)
	for i := 0; i <= N; i++ {
		var p int
		fmt.Scan(&p)
		A[i] = p
	}
	for i := 0; i < N; i++ {
		var p int
		fmt.Scan(&p)
		B[i] = p
	}
	cnt := 0
	for idx, b := range B {
		if A[idx] >= b {
			cnt += b
			continue
		}
		next := b - A[idx]
		if A[idx+1] >= next {
			cnt += b
			A[idx+1] -= next
			continue
		}
		cnt = cnt + A[idx] + A[idx+1]
		A[idx+1] = 0
	}
	fmt.Println(cnt)
}


Measured memory_bytes: 6912
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long int n,a[1005],b[1005],c[1005],d[1005],ans,i,j,l;
    memset(a,0,sizeof(a));
    memset(b,0,sizeof(b));
    memset(c,0,sizeof(c));
    memset(d,0,sizeof(d));
    scanf("%lld",&n);
    for(i=1;i<=n;i++)
    {
        scanf("%lld %lld",&a[i],&b[i]);
        c[i]=a[i];
        d[i]=b[i];
    }
    for(i=2;i<=n;i++)
    {
        l=j=0;
        if(d[i]<d[i-1])
            {j=d[i-1]/d[i];
        if(d[i-1]%d[i]!=0)
            j=j+1;}
        if(c[i]<c[i-1])
            {l=c[i-1]/c[i];
        if(c[i-1]%c[i]!=0)
            l=l+1;}

           //printf("%lld %lld\n",l,j);
           l=max(l,j);
           if(l!=0)
           {c[i]=a[i]*l;
           d[i]=b[i]*l;}

           // printf("%lld %lld\n",c[i],d[i]);
    }
    printf("%lld",c[n]+d[n]);
    return 0;

}

Measured memory_bytes: 256
def wczytaj_liste(): 
    wczytana_lista = input()
    lista_znakow = wczytana_lista.split()
    ostateczna_lista = []
    for element in lista_znakow:
        ostateczna_lista.append(int(element))
    return ostateczna_lista 

def AC_WC():
    N, M = wczytaj_liste()
    if N == M: 
        print('Yes')
    else: 
        print('No')
        
AC_WC()

Measured memory_bytes: 38384
#include <bits/stdc++.h>  
using namespace std;   
long long ll;  
int a[200005];  
int b[200005];  
int main()  
{  
    int n;  
    cin>>n;  
    for(int i=1;i<=n;i++){  
        cin>>a[i];  
        b[i]=a[i];  
   }  
   sort(a+1,a+1+n);  
    int mid=n/2;  
    for(int i=1;i<=n;i++){  
        if(b[i]<=a[mid])  
        printf("%d\n",a[mid+1]);  
        else  
        printf("%d\n",a[mid]);  
    }  
} 

Measured memory_bytes: 3712
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include <map>
#include <cmath>
#include <string>
#include <math.h>
using namespace std;

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

typedef long long ll;


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

int main() {
  int n, d, x;
  cin >> n >> d >> x;

  int a[n]; int chocolate[n] = { false };
  chocolate[0] = true;
  int eaten = 0;
  rep(i, n) {
      cin >> a[i];
      int count = 1; int day = a[i];
      while (day <= d-1)
      {
        /* code */
        count++;
        day += a[i];
      }
      eaten += count;
  }
  cout << eaten + x << endl;
  return 0;
}

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

#define rep(i,begin,end) for(int i=begin; i<end; i++)

int cmp(const void* a, const void* b){
    long long int x = *(long long int*)a, y = *(long long int*)b;
    if(x<y){
        return 1;
    }
    if(y<x){
        return -1;
    }
    return 0;
}

int main(){
    int x, y, z, k;
    scanf("%d %d %d %d", &x, &y, &z, &k);
    long long int a[x], b[y], c[z];
    rep(i, 0, x){
        scanf("%lld", &a[i]);
    }
    rep(i, 0, y){
        scanf("%lld", &b[i]);
    }
    rep(i, 0, z){
        scanf("%lld", &c[i]);
    }
    int buf = 0;
    long long int a_b[x*y];
    rep(a_i, 0, x){
        rep(b_i, 0, y){
            a_b[buf++] = a[a_i] + b[b_i];
        }
    }
    qsort(a_b, x*y, sizeof(long long int), cmp);
    int x_y = x*y;
    if(x_y > k){
        x_y = k;
    }
    long long int a_b_c[x_y * z];
    buf = 0;
    rep(ab_i, 0, x_y){
        rep(c_i, 0, z){
            a_b_c[buf++] = a_b[ab_i] + c[c_i];
        }
    }
    qsort(a_b_c, x_y*z, sizeof(long long int), cmp);
    rep(i, 0, k){
        printf("%lld\n", a_b_c[i]);
    }

    return 0;
}

Measured memory_bytes: 54908
#include <stdio.h>
int main(void)
{
  int a,b,c,flag=0;
  scanf("%d%d%d",&a,&b,&c);
  if(c>=a && c<=b)
  {
    flag=1;
  }
  if(flag)
  {
    printf("Yes\n");
  }
  else
  {
    printf("No\n");
  }
  return 0;
}


Measured memory_bytes: 128
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
const int N=5e5+5;
const ll MOD=1e9+7;
inline int read() {
	int x=0,f=1;char c=getchar();
	while (c<'0'||c>'9') {if (c=='-') f=-1;c=getchar();}
	while (c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
	return x*f;
}
ll fac[N]={1,1};
ll inv[N]={1,1};
int n,m;
inline ll fpow(ll a,int b) {
	ll ret=1;
	while (b) {
		if (b&1) ret=ret*a%MOD;
		b>>=1,a=a*a%MOD;
	}
	return ret;
}
inline ll C(int x,int y) {
	ll ans=fac[x];
	ans=ans*inv[y]%MOD;
	ans=ans*inv[x-y]%MOD;
	return ans;
}
inline ll P(int x,int y) {
	ll ans=fac[x];
	ans=ans*inv[x-y]%MOD;
	return ans;
}
inline void init() {
	for (register int i=1;i<N;++i) fac[i]=fac[i-1]*i%MOD;
	inv[N-1]=fpow(fac[N-1],MOD-2);
	for (int i=N-2;~i;--i) inv[i]=inv[i+1]*(i+1)%MOD;
}
int main() {
	n=read(),m=read();
	init();
	ll f=P(m,n);
	ll g=P(m,n),mk=1;
	for (register int i=1;i<=n;++i) {
		g-=mk*C(n,i)*P(m-i,n-i);
		g=(g%MOD+MOD)%MOD;
		mk=-mk;
	}
	ll ans=f*g%MOD;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 11440
#include<bits/stdc++.h>
using namespace std;
int main()
{
int a,b,c,e,i;
cin>>a>>b>>c;
if(b>c)swap(b,c);
for(i=b;i<=c;i++)
{
if(i%a==0){cout<<"OK";return 0;}}
cout<<"NG";
}

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

#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define pll         pair<long,long>
#define vi          vector<int>
#define vll         vector<ll>
#define vii         vector<pii>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define f         first
#define s           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define mod        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define rem(i,a,b)  for(int i=a;i>b;i--)
#define mp(a,b)     make_pair(a,b)

bool check(long n){
    for(int i=2;i*i<=n;i++){
        if(n%i==0)return false;
    }
    return true;
}

void solve(){
    long x;cin>>x;
    while(!check(x)){
        x++;
    }
    cout<<x;

}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    long t=1;
    //cin>>t;
    while(t--){

        solve();
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;

bool binary_search(int a[], int n, int key){
    int l = 0;
    int r = n;
    while(r - l > 1){
        int m = (l + r)/2;
        (a[m] > key) ? r = m : l = m;
    }
    return a[l] == key;
}

int main(){
    int n; cin >> n;
    int s[n];
    rep(i, n) cin >> s[i];
    int q; cin >> q;
    int t[q];
    rep(i, q) cin >> t[i];

    int ans = 0;
    rep(i, q) if(binary_search(s, n, t[i])) ans++;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3660
#include<iostream>
using namespace std;
 
int main(){
  int n, m;
  cin >> n >> m;
  for(int i=0;i<m;i++){
    int val;
    cin >> val;
    n -= val;
  }
  if(n >= 0)
    cout << n;
  else
    cout << -1;
  return 0;
}

Measured memory_bytes: 3192
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(long long i=0;i<n;i++)
#define REP1(i,n) for(long long i=1;i<=n;i++)
#define REPB(i,n) for(long long i=((n)-1);i>=0;i--)
#define REPB1(i,n) for(long long i=(n);i>0;i--)
#define ITE(arr) for(auto ite=(arr).begin();ite!=(arr).end();ite++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define YNPRT(b) cout<<((b)?"Yes":"No")<<endl
#define REV(arr) reverse(ALL(arr))
typedef long long ll;
typedef pair<int,int> pii;
//---------------------
#define MOD 1000000007
#define MAXN 100000
//---------------------
ll inv[MAXN];
ll fac[MAXN];
ll facinv[MAXN];


ll modpow(ll a, ll b){
  	if(b==-1) return inv[a];
  	if(b<-1) {
  		a=inv[a%MOD];
  		b*=-1;
  	}
	if(b==0) return 1;
	if(b==1) return a%MOD;
	ll ret=modpow(a%MOD,b>>1)%MOD;
	return (ret*ret%MOD)*((b%2)?(a%MOD):1)%MOD;
}

ll fermat(ll a){
  	if(a%MOD) return -1;
	return modpow(a,MOD-2);
}

inline ll modmult(ll a, ll b){
	return (a%MOD)*(b%MOD)%MOD;
}

inline ll modmult(ll a, ll b ,ll c){
	return (a%MOD)*(b%MOD)%MOD*(c%MOD)%MOD;
}


inline ll modfact(ll n){
	if(n==0 || n==1) return 1;
	if(n>=MOD) return 0;
	return fac[n];
}

inline ll modcomb(ll m, ll n){
  	if(m>=MOD || n>=MOD || n<0 || m<0) return -1;
  	if(n==0||n==m) return 1;
	return fac[m]*facinv[m-n]%MOD*facinv[n]%MOD;
}
      
void makelist(){
  	inv[0]=-1;
  	inv[1]=1;
	for(ll i=2;i<MAXN;i++) inv[i]=(MOD-MOD/i)*inv[MOD%i]%MOD;
	fac[0]=1;
	REP1(i,MAXN) fac[i]=(fac[i-1]*i)%MOD;
	facinv[MAXN-1] = modpow(fac[MAXN-1],MOD-2);
	REPB(i,MAXN-1) facinv[i]=(facinv[i+1]*(i+1))%MOD;
}


void makepowlist(ll *list,ll a,ll num){
	list[0]=1;
	REP1(i,num-1){
		list[i] = modmult(list[i-1],a);
	}
}


void makepowinvlist(ll *list, ll a,ll num){
	list[0]=1;
	REP1(i,num-1){
		list[i] = modmult(list[i-1],inv[a]);
	}
}

ll n,m,a[MAXN+5],rsize=0;
ll ret=1;
int main(){
  	makelist();
  	cin>>n>>m;
  	ll lasta=-5;
  	
  	REP1(i,m) {
  		ll tp=0;
  		cin>>tp;
  		if(i>0){if(tp==a[i-1]) continue; else {a[i]=tp;rsize++;}}
  		else{
  			a[0]=tp;
  			rsize=1;
  		}
  		if(tp-lasta==1) {cout<<0<<endl;return 0;}
  		lasta=tp;
  	}
  	rsize+=2;
  	a[0]=-1;
  	a[m+1]=n+1;
  	
  	if(rsize>=2){
  		REP(i,rsize-1){
  			ll num=a[i+1]-a[i]-1;
  			//cout<<num<<endl;
  			if(num<=2) continue;
  			ll step2=0,step1=num-1;
  			ll retnum=1;
  			while(step1-2>=0){
  				step1-=2;
  				step2+=1;
  				retnum=(retnum+modcomb(step1+step2,step2))%MOD;
  			}
  			ret=modmult(ret,retnum);
  		}
  	}
  	
  	cout<<ret<<endl;
  	
  	

	return 0;
}

Measured memory_bytes: 2944
n = int(input())
A = list(map(int, input().split()))
absA = [abs(a) for a in A]

if sum(True if a < 0 else False for a in A) % 2 == 0:
  ans = sum(absA)
else:
  ans = sum(absA) - 2 * min(absA)
  
print(ans)

Measured memory_bytes: 20028
#include <limits.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <math.h>

#define P 1000000007

int comp(const void *a, const void *b){return *(int*)a-*(int*)b;}

char s[2000][2001];
short d[2000][2000][4];
int main(void){
	int h, w, i, j;
	scanf("%d %d", &h, &w);
	for(i=0; i<h; i++){
		scanf("%s", s[i]);
	}
	int f, g;
	for(i=0; i<h; i++){
		f=0;
		for(j=0; j<w; j++){
			if(s[i][j]=='.'){
				if(f==0){ f=1; g=j; }
				d[i][j][0]=j-g;
			}else{
				f=0;
			}
		}
	}
	for(i=0; i<h; i++){
		f=0;
		for(j=w-1; j>=0; j--){
			if(s[i][j]=='.'){
				if(f==0){ f=1; g=j; }
				d[i][j][1]=g-j;
			}else{
				f=0;
			}
		}
	}
	for(j=0; j<w; j++){
		f=0;
		for(i=0; i<h; i++){
			if(s[i][j]=='.'){
				if(f==0){ f=1; g=i; }
				d[i][j][2]=i-g;
			}else{
				f=0;
			}
		}
	}
	for(j=0; j<w; j++){
		f=0;
		for(i=h-1; i>=0; i--){
			if(s[i][j]=='.'){
				if(f==0){ f=1; g=i; }
				d[i][j][3]=g-i;
			}else{
				f=0;
			}
		}
	}
	int ans=0;
	for(i=0; i<h; i++){
		for(j=0; j<w; j++){
			if(s[i][j]=='.'){
				int now=d[i][j][0]+d[i][j][1]+d[i][j][2]+d[i][j][3]+1;
				if(now>ans) ans=now;
			}
		}
	}
	printf("%d\n", ans);
}


Measured memory_bytes: 35328
loop {
	n=gets.chomp.to_i
	break if n==0
	matrix=Array.new(n+1,Array.new(n+1,0))


	for i in 0..n-1
		matrix[i] = gets.chomp.split(" ").map{|i| i.to_i}
		matrix[i][n] = matrix[i].inject(:+)
		for j in 0..n	
			matrix[n][j] += matrix[i][j]
		end
	end

	for i in 0..n
		puts matrix[i].map{|j| j.to_s.rjust(5)}.join
	end

}

Measured memory_bytes: 8776
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <cmath>
using namespace std;

int main(){
    int n ;
    cin >> n ;
    vector<int> a(n) ;
    for (size_t i = 0; i < n; i++)
    {
        cin >> a.at(i) ;
    }
    sort(a.begin(), a.end()) ;
    for (size_t i = 0; i < n-1; i++)
    {
        if (a.at(i) == a.at(i+1))
        {
            cout << "NO" << endl ;
            return 0 ;
        }
        
    }
    cout << "YES" << endl ;
    
}    

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

//繰り返し自乗法(modなし)
ll mypow(ll x, ll n){
  if(n == 0)
    return 1;
 
  if(n % 2 == 0)
    return mypow(x * x, n / 2);
  else
    return x * mypow(x, n - 1);
}

int main() {
  int n,m;
  cin >> n >> m;
  int ans = ((n - m) * 100 + m * 1900) * mypow(2, m);
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main() {
   cin.tie(0);
   ios::sync_with_stdio(false);
   int n;
   cin >> n;
   vector<int> vc(n);
   for(int i = 0;i < n;i++) {
       cin >> vc[i];
   }
   sort(vc.begin(), vc.end());
   cout << vc[vc.size()-1]-vc[0] << endl;
}

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

#define rng(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define per(i, b) gnr(i, 0, b)

using namespace std;

using ll = long long;
using P = pair<int, int>;

int main() {
  int n;
  cin >> n;
  vector<string> s(n);
  rep(i, n) cin >> s.at(i);
  int ac = 0;
  int wa = 0;
  int tle = 0;
  int re = 0;
  rep(i, n) {
    string x = s.at(i);
    if (x == "AC") {
      ac++;
    } else if (x == "WA") {
      wa++;
    } else if (x == "TLE") {
      tle++;
    } else if (x == "RE") {
      re++;
    }
  }
  cout << "AC x " << ac << endl;
  cout << "WA x " << wa << endl;
  cout << "TLE x " << tle << endl;
  cout << "RE x " << re << endl;
  return 0;
}


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

int main() {
  int n,k;
  cin >> n >> k;
  vector<char> s(n);
  for(int i =0;i<n;i++){
    cin >> s.at(i);
  }
  if( s.at(k-1) == 'A'){
    s.at(k-1) = 'a';
  }
  if( s.at(k-1) == 'B'){
    s.at(k-1) = 'b';
  }
  if( s.at(k-1) == 'C'){
    s.at(k-1) = 'c';
  }
  for(int i = 0 ;i<n;i++){
    cout << s.at(i);
  }
  cout << endl;
}



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

using namespace std;

int main()
{
	int n, m;

	scanf("%d %d", &n, &m);

	printf("%d\n", (n + m * 2) / (m * 2 + 1));

	return 0;
}

Measured memory_bytes: 128
#include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<iostream>
using namespace std;
const int N = 100;
int n,m;
char s[N];
int a[10][4];
int b[3];
vector<int> an;
void work(char *s,int mark) {
    int cnt = 0;
    int fg = 1;
    for (int i = 0; i < 3; i++) {
        a[mark][i] = b[i];
    }
    for (int i = 0; s[i]; i++) {
        if (s[i] == '.' && fg) cnt++;
        if (s[i] != '.') fg = 0;
        if (s[i] == '(') b[0]++;
        if (s[i] == ')') b[0]--;
        if (s[i] == '{') b[1]++;
        if (s[i] == '}') b[1]--;
        if (s[i] == '[') b[2]++;
        if (s[i] == ']') b[2]--;
    }
    a[mark][3] = cnt;
   
}
void solve(char *s,int mark){
    if (mark == 0) {
        an.push_back(0);
    }else {
        int fg = 0;
        int val = 0;
        for (int i = 1; i <= 20; i++) {
            for (int j = 1; j <= 20; j++) {
                for (int k = 1; k <= 20; k++) {
                    int f = 1;
                    for (int p = 0; p < n && f; p++) {
                        int sm = i * a[p][0] + j * a[p][1] + k * a[p][2];
                        if (sm != a[p][3]) f = 0;
                    }
                    if (f) {
                        int sm = i * b[0] + j * b[1] + k * b[2];
                        if (fg == 0 || sm != val) {
                            val = sm;
                            fg++;
                        }
                    }
                }
            }
        }
        if (fg == 1) an.push_back(val);
        else an.push_back(-1);
    }
    for (int i = 0; s[i]; i++) {
        if (s[i] == '(') b[0]++;
        if (s[i] == ')') b[0]--;
        if (s[i] == '{') b[1]++;
        if (s[i] == '}') b[1]--;
        if (s[i] == '[') b[2]++;
        if (s[i] == ']') b[2]--;
    }
}
int main(){
    while (~scanf("%d%d",&n,&m),n+m) {
        getchar();
        memset(a,0,sizeof(a));
        memset(b,0,sizeof(b));
        for (int i = 0; i < n; i++) {
            gets(s);
            //cout<<s<<endl;
            work(s,i);
        }
        memset(b,0,sizeof(b));
        an.clear();
        for (int i = 0; i < m; i++) {
            gets(s);
           // cout<<s<<endl;
            solve(s,i);
        }
        int sz = an.size();
        for (int i = 0; i < sz; i++) {
            printf("%d%c",an[i],i == sz - 1 ? '\n' : ' ');
        }
    }


    return 0;
}
/*
.
............................................................
............................................................
*/

Measured memory_bytes: 1220