akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
char s[1000010];
int main() {
	int n, q;
	scanf("%d%s%d", &n, s, &q);
	while (q--) {
		int l;
		scanf("%d", &l);
		long long ans = 0, dc = 0, dm = 0, sdp = 0;
		for (int i = 0; i < n; i++) {
			if (i >= l) {
				if (s[i-l] == 'D') {
					--dc;
					sdp -= dm;
				} else if (s[i-l] == 'M') {
					--dm;
				}
			}
			if (s[i] == 'D') {
				++dc;
			} else if (s[i] == 'M') {
				++dm;
				sdp += dc;
			} else if (s[i] == 'C') {
				ans += sdp;
			}
		}
		printf("%lld\n", ans);
	}
	return 0;
}


Measured memory_bytes: 1152
def GCD(a, b):
	if b > a:
		tmp = a
		a = b
		b = tmp
	if a % b == 0:
		return b
	return GCD(b, a % b)

def LCM(a, b):
	return a * b / GCD(a, b)

def judge():
	N, M = map(int, raw_input().split())
	S = raw_input()
	T =raw_input()
	L = LCM(N, M)
	S_pos = [0] * N
	T_pos = [0] * M
	for i in range(N):
		S_pos[i] = i * L/N
	for i in range(M):
		T_pos[i] = i * L/M
	i = 0
	j = 0
	while i < N and j < M:
		if S_pos[i] == T_pos[j]:
			if S[i] != T[j]:
				return -1
			i += 1
			j += 1
		elif S_pos[i] < T_pos[j]:
			i += 1
		else:
			j += 1
	return L

print judge()


Measured memory_bytes: 11068
#include<bits/stdc++.h>
#define pb push_back
#define ii pair<int,int>
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define INF 100000000000000000
#define modulo 1000000007
#define mod 998244353
#define int long long int
using namespace std;


int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	int n, k;
	cin >> n >> k;
	vector<bool> vis(n + 1, true);

	while(k--){
		int d;
		cin >> d;
		while(d--){
			int x;
			cin >> x;
			vis[x] = false;
		}
	}
	int ans = 0;
	for(int i = 1; i <= n; i++) if(vis[i]) ans++;

	cout << ans;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iostream>
#include <bitset>
#include <cassert>
#include <queue>
#include <random>
#include <stack>
#include <iomanip>
#include <math.h>
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define repf(i, a, b) for (ll i = (ll)a; i < (ll)b; i++)
#define repr(i, a, b) for (ll i = (ll)a; i > (ll)b; i--)
#define repv(x, arr) for (auto &x : arr)
#define all(v) (v).begin(), (v).end()
#define vec(name, num) vector<ll> name((num), 0);
#define mp(a, b) make_pair(a, b)
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int infi = 2147483600;
const ll infl = 1e17;

int main()
{
    int n;
    cin>>n;
    vii a(n);
    rep(i,n)cin>>a[i];
    rep(i,n){
        if (a[i]>i+1){
            cout << -1 << endl;
            return 0;
        }
    }
    vii ans(n);
    rep(i,n){
        repr(j,a.size()-1,-1){
            if (j+1==a[j]){
                ans[i] = a[j];
                repf(k,j,a.size()-1){
                    a[k] = a[k + 1];
                }
                a.pop_back();
                break;
            }
        }
    }
    repr(i, n - 1, -1) cout << ans[i] << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <list>
#include <algorithm>
#include <cmath>
#include <stack>
#include <set>
using namespace std;

#define REP(i,n) for(int (i)=0; (i)<(n); (i)++)
#define FOR(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define PUSH(n,v) for(int i=0; i<(n); i++) {int j; cin >> j; v.push_back(j);}
#define ALL(v) v.begin(), v.end()

int main() {
    int i;
    while(cin >> i) {
        int s = 0;
        for(int j = 0; j < 600; j+=i) {
            s += i * j*j;
        }
        cout << s << endl;
    }
    return 0;
}

Measured memory_bytes: 1160
s = gets().chomp.split('')

is_easy = true

s_even = []
s_odd = []
s.each_with_index do |c, i|
  if i.odd?
    s_even.push(c)
  else
    s_odd.push(c)
  end
end

is_easy = false if s_even.include?('R')
is_easy = false if s_odd.include?('L')

puts is_easy ? 'Yes' : 'No'

Measured memory_bytes: 14300
#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>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;
    int ans = 1e9;
    int mi = min(x,y), ma = max(x,y);
    chmin(ans, a*x+b*y);
    chmin(ans, c*2*x + b*max(0,y-x));
    chmin(ans, c*2*y + a*max(0,x-y));
    chmin(ans, c*ma*2);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

void Main()
{
  int n;
  cin >> n;
  vector<string> s(n);
  REP(i, n)
  cin >> s[i];
  
  int AC = 0;
  int WA = 0;
  int TLE = 0;
  int RE = 0;
  
  for(int i = 0; i < n; i++){
    
    if(s[i][0] == 'A' && s[i][1] == 'C')
      AC++;
    
    else if(s[i][0] == 'W' && s[i][1] == 'A')
      WA++;
    
    else if(s[i][0] == 'R' && s[i][1] == 'E')
      RE++;
    
    else if(s[i][0] == 'T' && s[i][1] == 'L' && s[i][2] == 'E')
      TLE++;
      
  }
  
  printf("AC x %d\n", AC);
  printf("WA x %d\n", WA);
  printf("TLE x %d\n", TLE);
  printf("RE x %d\n", RE);
    
    
  
    
}

int main()
{
  std::cout << std::fixed << std::setprecision(15);
  Main();
}



Measured memory_bytes: 6372
#include<bits/stdc++.h>
#define pb emplace_back
using namespace std;
using ll = long long;
#ifdef KEV
#define DE(i, e) cerr << #i << ' ' << i << e
void debug(auto L, auto R) { while (L < R) cerr << *L << " \n"[L+1==R], ++L; }
#else
#define DE(...) 0
void debug(...) {}
#endif
const int maxn = 300010;
signed main(){
	ios_base::sync_with_stdio(0), cin.tie(0);
	string a;
	cin >> a;
	cout << a.substr(0, 4) << ' ' << a.substr(4) << '\n';
}



Measured memory_bytes: 3516
#include<stdio.h>

#define N 100

int main(){
  int i, j, minj, A[N], n, a, cnt=0;

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

  for(i = 0; i < n; i++){
    minj = i;
    for(j = i; j < n; j++){
      if(A[j] < A[minj]){
	minj = j;
      }
    }
    a = A[i];
    A[i] = A[minj];
    A[minj] = a;
    if(i != minj) cnt++;
  }

  for(i = 0; i < n-1; i++){
    printf("%d ", A[i]);
  }
  printf("%d\n%d\n", A[i],cnt);


  return 0;
}

Measured memory_bytes: 600
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <regex>
#include <vector>

#define fix(n)          cout<<fixed<<setprecision(n)
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define all(a)          (a).begin(), (a).end()
#define sort(a)         sort(all(a))
#define uniq(a)         sort(a);(a).erase(unique(all(a)), (a).end())
#define reverse(a)      reverse(all(a))
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d)
#define outl(d)         std::cout<<(d)<<"\n"
#define YES()           cout << "YES" << endl
#define NO()            cout << "NO" << endl
#define Yes()           cout << "Yes" << endl
#define No()            cout << "No" << endl
#define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }
#define pb              push_back
#define fst             first
#define int             long long
#define INF             __LONG_LONG_MAX__

using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;

const ll MOD = 1000000007; // 10^9 + 7
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

bool check(string s) {
  stack<bool> left, right; // 括弧の種類
  for (int i = 0; i < s.size(); i++) {
    char c = s[i];
    if (c != '(' && c != ')' && c != ']' && c != '[') continue;

    if (c == '(' || c == '[') {
      // debug3(1, i, c);
      left.push(c == '(');
    } else if (left.empty()) {
      // debug3(2, i, c);
      return false;
    } else if ((c == ')') == left.top()) {
      // debug3(3, i, c);
      left.pop();
    } else {
      // debug3(4, i, c);
      return false;
    }
  }
  // debug2(left.size(), right.size());
  return left.empty() && right.empty();
}

void solve() {
  while (true) {
    string s; getline(cin, s);
    if (s == ".") break;
    if (check(s)) outl("yes");
    else outl("no");
  }
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12);

  solve();
}



Measured memory_bytes: 3092
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstddef>
#include<queue>
#include<math.h>
#include<iomanip>
using namespace std;

int main()
{
    long long X, a = 0, b = 0;
    cin >> X;
    a = X / 500;
    b = (X % 500) / 5;
    cout << 1000 * a + b * 5<< endl;
    return 0;
}

Measured memory_bytes: 256
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
def main():
    w, h, x, y = map(int, input().split())
    if x == 0 or y == 0:
        print(w * h / 2, 0)
    elif w / x == 2 and h / y == 2:
        r = x * h
        print(r, 1)
    else:
        print(w * h / 2, 0)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9176
import java.io.IOException;
import java.io.InputStream;
import java.math.BigInteger;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.NoSuchElementException;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Scanner;
import java.util.Set;

public class Main {

	static Scanner sc = new Scanner(System.in);

	static class FastScanner {
		private final InputStream in;
		private final byte[] buffer = new byte[1024];
		private int ptr = 0;
		private int buflen = 0;

		public FastScanner(InputStream source) {
			in = source;
		}

		private boolean hasNextByte() {
			if (ptr < buflen) {
				return true;
			} else {
				ptr = 0;
				try {
					buflen = in.read(buffer);
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (buflen <= 0) {
					return false;
				}
			}
			return true;
		}

		private int readByte() {
			if (hasNextByte()) return buffer[ptr++];
			else return -1;
		}

		private static boolean isPrintableChar(int c) {
			return 33 <= c && c <= 126;
		}

		public boolean hasNext() {
			while (hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;
			return hasNextByte();
		}

		public String next() {
			if (!hasNext()) throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while (isPrintableChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}

		public long nextLong() {
			if (!hasNext()) throw new NoSuchElementException();
			long n = 0;
			boolean minus = false;
			int b = readByte();
			if (b == '-') {
				minus = true;
				b = readByte();
			}
			if (b < '0' || '9' < b) {
				throw new NumberFormatException();
			}
			while (true) {
				if ('0' <= b && b <= '9') {
					n *= 10;
					n += b - '0';
				} else if (b == -1 || !isPrintableChar(b)) {
					return minus ? -n : n;
				} else {
					throw new NumberFormatException();
				}
				b = readByte();
			}
		}

		public int nextInt() {
			long nl = nextLong();
			if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
				throw new NumberFormatException();
			return (int) nl;
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}
	}

	public static void main(String[] args){

		solve_abc162_c();
	}
  
  	public static void solve_abc162_c(){

		FastScanner sc = new FastScanner(System.in);
		
		int n = sc.nextInt();
		long sum = 0;
		
		for(int i=1;i<=n;i++){
			for(int j=1;j<=n;j++){
				
				int x = solve_abc162_c_euclid(i,j);
				
				
				for(int k=1;k<=n;k++){
					
					int y = solve_abc162_c_euclid(x, k);
					sum += y;
					
				}
				
			}
		}

		System.out.println(sum);

	}

	
    public static int solve_abc162_c_euclid( int a, int b ) {
        if( a < b ) { int temp = a; a = b; b = temp; } //引数の大小入替
        if( b < 1 ) return -1;                         //0以下は非自然数

        if( a % b == 0 ) return b;
        return solve_abc162_c_euclid( b, a % b );
    }
}

  

Measured memory_bytes: 27208
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n, W;
    cin >> n >> W;
    vector<int> value(n);
    vector<int> weight(n);
    for (int i = 0; i < n; i++)
    {
        cin >> weight[i] >> value[i];
    }
    // dp[i][j]=minimum bag capacity required to get max j profit considering first i elements

    // cout << n << " " << W << " " << weight.size() << endl;
    long long dp[n + 1][100001];
    for (int i = 0; i <= n; i++)
    {
        // cout << 54484 << endl;
        dp[i][0] = 0;
        for (int j = 1; j < 100001; j++)
            dp[i][j] = LONG_LONG_MAX;
    }
    // cout << "DSvdsv";
    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j < 100001; j++)
        {
            //discard element
            dp[i][j] = dp[i - 1][j];

            //pick element
            if (j - value[i - 1] >= 0 && dp[i - 1][j - value[i - 1]] != LONG_LONG_MAX)
                dp[i][j] = min(dp[i][j], (long)weight[i - 1] + dp[i - 1][j - value[i - 1]]);
        }
    }
    int ans;
    for (int myans = 100000 ; myans >= 0; myans--)
    {
        if (dp[n][myans] <= W)
        {
            ans = myans;
            break;
        }
    }
    // cout << "arjun" << endl;
    cout << ans << endl;
}

Measured memory_bytes: 82536
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <regex>
#include <vector>

#define fix(n)          cout<<fixed<<setprecision(n)
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define sort(a)         sort((a).begin(), (a).end())
#define uniq(a)         sort(a);(a).erase(unique((a).begin(), (a).end()), (a).end())
#define reverse(a)      reverse((a).begin(), (a).end())
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d)
#define outl(d)         std::cout<<(d)<<"\n"
#define YES()           cout << "YES" << endl
#define NO()            cout << "NO" << endl
#define Yes()           cout << "Yes" << endl
#define No()            cout << "No" << endl
#define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }

using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;

const ll MOD = 1000000007; // 10^9 + 7

void solve() {
  priority_queue<P> q;
  ll n, m; cin >> n >> m;
  rep(i, n) {
    ll a, b; cin >> a >> b;
    q.push(make_pair(-a, b));
  }

  ll ans = 0;
  while (!q.empty() && m > 0) {
    P v = q.top(); q.pop();
    int pr = -v.first;
    // debug3(m, pr, v.second);
    ans += min(m, v.second) * pr;
    m -= min(m, v.second);
  }
  outl(ans);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12);

  solve();
}


Measured memory_bytes: 2420
#include<bits/stdc++.h>
typedef long long int ll;
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cout.tie(0);cin.tie(0);

const ll mod=1e9+9;
const ll MAXN=5e3+5;
const ll inf=1e17;

int main()
{
    fastio;
    ll n;
    cin>>n;
    map<ll,ll > mp;
    bool ok=true;
    for(int i=0;i<n;i++){
        ll a;
        cin>>a;
        if(mp.count(a)) ok=false;
        else mp[a]=2;
    }
    if(ok) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}


Measured memory_bytes: 12800
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <string>

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define mp make_pair
#define bg begin()
#define en end()
#define all(v) (v).begin(), (v).end()
#define sz(v) (int)(v).size()


using namespace std;

typedef long long ll;

static const long long MOD = 1000000007;
static const long long INF = 1<<31;

ll ans, a[200005], s, k, r[200005];
map<ll, ll> m;
int n;

int main(void) {
  cin >> n >> k;
  rep(i, 1, n+1) scanf("%lld", &a[i]);
  m[0]++;
  rep(i, 1, n+1) {
    if (i>=k) m[r[i-k]]--;
    s += a[i];
    ll t = (s - i)%k;
    if (t<0) t += k;
    //cout << t << endl;
    ans += m[t];
    m[t]++;
    r[i] = t;
  }
    
    cout << ans << "\n";

    return 0;
}



Measured memory_bytes: 15872
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;
typedef string::const_iterator State;
#define Ma_PI 3.141592653589793
#define eps 1e-5
#define LONG_INF 2000000000000000000LL
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL
#define MOD 998244353LL
#define seg_size 262144
#define REP(a,b) for(long long a = 0;a < b;++a)
int main(){
	long long x;
	cin >> x;
	long long hoge = x / 100;
	x %= 100;
	if (5 * hoge >= x) {
		cout << "1" << endl;
	}
	else {
		cout << 0 << endl;
	}
}

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

int main(){
     int n,k;
    cin>>n>>k;
    vector<double>p(n);
    vector<double>sum(n+1);
    for(int i=0; i<n; i++){
        cin>>p.at(i);
        double bu=(1+p.at(i))/2;
        sum.at(i+1)=sum.at(i)+bu;
    }
    double mak=0;
    for(int i=k; i<n+1; i++){
        mak=max(mak,sum.at(i)-sum.at(i-k));
    }
    cout << fixed << setprecision(5);
    cout<<mak<<endl;
}

Measured memory_bytes: 3328
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <array>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>
#include <stack>
#include <utility>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <bitset>
#include <random>
#include <functional>
#include <sstream>
#include <iomanip>

using namespace std;

#define _CRT_SECURE_NO_WARNINGS
#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back

typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef long long LL;

//最大公約数
LL gcd(LL n, LL m) {
	if (m == 0)return n;
	return gcd(m, n%m);
}

//最小公倍数
LL lcm(LL n, LL m) {
	LL g = gcd(n, m);
	return n / g * m;
}

int main() {
	LL a, b;
	while (cin >> a >> b) {
		cout << gcd(a, b) << " " << lcm(a, b) << endl;
	}
}


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

#define ll long long
#define lli long long int
#define loop(i,x,n) for(lli i=x; i<=n; i++)
#define rloop(i,n,x) for(lli i=n; i>=x; i--)

typedef vector<ll> v64;
typedef vector<pair<ll,ll>> vp64;
typedef vector<bool> vbo;
typedef set<ll> s64;
typedef set<bool> sbo;
typedef unordered_set<ll> us64;
typedef map<ll,ll> m64;
typedef unordered_map<ll,ll> um64;

int main(){
    int n;
    cin>>n;
    int a[n];
    for(int i=0; i<n; i++) cin>>a[i];
    int ans = 0;
    int check[n];
    check[n-1] = 0;
    for(int i=n-2; i>=0; i--){
        if(a[i]>=a[i+1]) check[i] = check[i+1]+1;
        else check[i] = 0;
        ans = max(ans,check[i]);
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  int ans=0;
  cin>>s;
  for(int i=0;i<(int)s.size()/2;i++){
    if(s[i]!=s[(int)s.size()-i-1]){
      ans++;
    }
  }
  cout<<ans<<endl;
  return(0);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{long long i,j,k,l,m,n,t,z,sum,x,y;
cin>>n;x=0;
for(i=1;i<n;i++)
{y=n/i;if(n%i==0)y=y-1;
x=x+y;}
cout<<x;
return 0;}


Measured memory_bytes: 3672
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int aa[4010][3],n;
char s[4010];
long long dfs(char a,char b,char c){
	long long temp=0;
	for(int i=1;i<=n;i++){
		if(s[i]==a){
			for(int j=i+1;j<=n;j++){
				if(s[j]==b){
					if(c=='R'){
						temp+=aa[n][0]-aa[j][0];
						if((2*j-i)<=n&&s[2*j-i]=='R'){
							temp--;
						}
					}
					else if(c=='G'){
						temp+=aa[n][1]-aa[j][1];
						if((2*j-i)<=n&&s[2*j-i]=='G'){
							temp--;
						}
					}
					else{
						temp+=aa[n][2]-aa[j][2];
						if((2*j-i)<=n&&s[2*j-i]=='B'){
							temp--;
						}
					}
					
				}
			}
		}
	}
	return temp;
}
int main(){
	long long ans=0;
	scanf("%d%s",&n,s+1);
	memset(aa,0,sizeof(aa));
	for(int i=1;i<=n;i++){
		if(s[i]=='R'){
			aa[i][0]=aa[i-1][0]+1;
			aa[i][1]=aa[i-1][1];
			aa[i][2]=aa[i-1][2];
		}
		else if(s[i]=='G'){
			aa[i][0]=aa[i-1][0];
			aa[i][1]=aa[i-1][1]+1;
			aa[i][2]=aa[i-1][2];
		}
		else{
			aa[i][0]=aa[i-1][0];
			aa[i][1]=aa[i-1][1];
			aa[i][2]=aa[i-1][2]+1;
		}
	}
	ans+=dfs('R','G','B');
	ans+=dfs('R','B','G');
	ans+=dfs('G','R','B');
	ans+=dfs('G','B','R');
	ans+=dfs('B','R','G');
	ans+=dfs('B','G','R');
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 3780
import java.util.*;

public class Main {
  public static void main(String[] srgs) {
    Scanner sc = new Scanner(System.in);
    int n = Integer.parseInt(sc.next());
    final long t = Long.parseLong(sc.next());
    int[] time = new int[n];
    long ans = 0;
    for(int i = 0; i < n; i++) {
      time[i] = Integer.parseInt(sc.next());
    }
    for(int i = 0; i < n - 1; i++) {
      ans += Math.min(time[i+1] - time[i], t);
    }
    System.out.println(ans + t);
  }
}


Measured memory_bytes: 48812
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); ++i)
int main(){
  int a,b,c;
  std::cin >> a>>b>>c;
  if(a==b && a!=c)std::cout << "Yes" << '\n';
  else if(a==c && a!=b)std::cout << "Yes" << '\n';
  else if(b==c && a!=b)std::cout << "Yes" << '\n';
  else std::cout << "No" << '\n';
  return 0;

}


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

int main () {
  	int H, W;
  	cin >> H >> W;
  	string a[H];
  	for (int i = 0; i < H; i++) {
    	cin >> a[i];
  	}
	vector<bool> row (H,false);
	vector<bool> col (W,false);
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (a[i][j] == '#') {
				row[i] = true;
				col[j] = true;
			}
		}
	}
 
	for (int i = 0; i < H; i++) {
		if (row[i]) {
			for (int j = 0; j < W; j++) {
				if (col[j]) {
					cout << a[i][j];
				}
			}
			cout << endl;
		}
	}
}

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

const int64_t mod=1e9+7;

int64_t modinv(int64_t x, int64_t m) {
  int64_t y=m, u=1, v=0;
  while(y) {
    int64_t t=x/y;
    x -= t*y;
    swap(x,y);
    u -= t*v;
    swap(u,v);
  }
  u %= m;
  if(u<0)
    u+=m;
  return u;
}

int64_t cm(int n, int k) {
  int i;
  int64_t r=1,x=1,y=1;
  if(n<k)
    return 0;
  else if(n==k)
    return 1;
  else if(k==1)
    return n;
  if(k>n-k)
    k=n-k;
  for(i=0; i<k; i++) {
    x*=n-i;
    y*=k-i;
    x%=mod;
    y%=mod;
  }
  return x*modinv(y,mod)%mod;
}

int main() {
  int N,K,i;
  cin >> N >> K;
  for(i=0; i<K; i++)
    cout << (cm(N-K+1, i+1)*cm(K-1, i))%mod << endl;
}

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

int main() {
   for (int i = 0; i < 5; i++) {
       int tmp;
       cin >> tmp;
       if (tmp != i+1) {
           cout << i+1 << endl;
           break;
       }
   }
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000007;

int memo[110000];
int rec(int N){
  if (N == 0) return 0;
  if (memo[N] != -1) return memo[N];

  int res = N;
  int pow6 = 1; 
  while(pow6 <= N){
    pow6 *= 6;
  }
  res = rec(N-pow6/6) + 1;
  int pow9 = 1;
  while(pow9 <= N){
    pow9 *= 9;
  }
  res = min(res, rec(N-pow9/9) + 1);

  return memo[N] = res;
}
 
int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);

  int n;
  cin >> n;

  for(int i=0;i < 110000;i++){
    memo[i] = -1;
  }
  cout << rec(n) << endl;
}

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

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

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

    int n, x;
    cin >> n >> x;

    vector<int> A(n + 1);
    REP(i, n) cin >> A[i];
    A[n] = x;

    sort(A.begin(), A.end());


    vector<int> B(n); 
    REP(i, n){
        B[i] = A[i + 1] - A[i];
    }
	
    int g;
  	if(n==1)g = B[0];
  	else g = gcd(B[0], B[1]);
    for(int i = 1; i < n; i++){
        g = gcd(g, B[i]);
    }

    cout << g << endl;

    return 0;
}


Measured memory_bytes: 1024
n=int(input())
l=[]
for i in range(300):
  l.append(i**2)
l=set(l)
for i in range(1,n+1):
  ct=0
  for j1 in range(1,int(n**0.5)+2):
    for j2 in range(1,int(n**0.5)+2):
      a=j1+j2
      b=i-j1**2-j2**2-j1*j2
      if a**2+4*b in l:
        k=int((a**2+4*b)**0.5)
        if (a+k)%2==0:
          j3=(-a+k)//2
          if j3>0:
            ct+=1
  print(ct)

Measured memory_bytes: 74628
#include<bits/stdc++.h>
using namespace std;
#define ll                          long long
#define in(a)                       ll a; cin>>a;
#define in2(a,b)                    ll a,b; cin>>a>>b;
#define in3(a,b,c)                  ll a,b,c; cin>>a>>b>>c;
#define in4(a,b,c,d)                ll a,b,c,d; cin>>a>>b>>c>>d;
#define in5(a,b,c,d,e)              ll a,b,c,d,e; cin>>a>>b>>c>>d>>e;
#define lelo(b)                     for(auto &i:b)cin>>i;
#define ff                          first
#define ss                          second
#define call(v)                     v.begin(),v.end()
#define rall(v)                     v.rbegin(),v.rend()
#define show(x)                     for(auto t:x)cout<<t<<" ";
#define pb                          push_back
#define bhar(s,v)                   memset(s,v,sizeof(s))
#define endl                        "\n"                       
#define ce(x)                       cout<<x<<"\n";
#define nl                          cout<<endl;
#define jaldi                       ios_base::sync_with_stdio(false);cin.tie(NULL);
#define dekh_lo                     ce("dekh_lo");
#define sz(x)                       (ll)x.size()
#define re                          return

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

typedef pair<ll,ll> pii;
typedef vector<pii> vii;
typedef vector<ll> vi;

const ll mod=1e9+7;
const ll N=4e5+5;
ll i,j;

/*


*/

ll dp[1005][1005];
void solve(){
	bhar(dp,0);
    in2(h,w);
    std::vector<string> v(h); lelo(v);
    dp[0][0]=1;
    bool f=0;
    for(i=0;i<h;i++){
    	if(v[i][0]=='.'){
    		dp[i][0]=1;
    	}
    	else{
    		f=1;
    		break;
    	}
    }
    f=0;
    for(j=0;j<w;j++){
    	if(v[0][j]=='.'){
    		dp[0][j]=1;
    	}
    	else{
    		break;
    	}
    }
    for(i=1;i<h;i++){
    	for(j=1;j<w;j++){
    		if(v[i][j]=='.'){
    			dp[i][j]=(dp[i-1][j]+dp[i][j-1])%mod;
    		}
    	}
    }
    ce(dp[h-1][w-1]);
}

int32_t main(){
    // jaldi
    ll t; 
    // cin>>t;
    t=1;     
    while(t--){
        solve();
    }
}

/*


*/

  


Measured memory_bytes: 13424
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Queue;
import java.util.Scanner;
import java.util.Set;

public class Main {

	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args){

		solve_abc157_c();
	}
  
  	public static void solve_abc157_c(){

		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		int M = sc.nextInt();
		
		int s[] = new int[3];
		
		for(int i=0;i<3;i++){
			s[i] = -1;
		}
		
		boolean ans = true;
		
		for(int i=0;i<M;i++){
			
			int c = sc.nextInt();
			int d = sc.nextInt();
			
			if(s[c-1+(3-N)] == -1 || s[c-1+(3-N)] == d) s[c-1+(3-N)] = d;
			else ans = false;
		}
		
		//System.out.print(s[0]);
		//System.out.print(s[1]);
		//System.out.print(s[2]);
		
		if(!ans){
			System.out.println("-1");
			sc.close();
			return;
		}

		if(N != 1 && s[3-N] == 0){
			System.out.println("-1");
			sc.close();
			return;
		}

		
		for(int i=3-N;i<3;i++){
			if(i == 3-N && N != 1 && s[i] == -1){
				s[i] = 1;
			}
			else if(s[i] == -1){
				s[i] = 0;
			}
			
			System.out.print(s[i]);
		}

		sc.close();

	}
}

Measured memory_bytes: 23760
#include<stdio.h>
int main(){
	int a,b,c,d,e,i,j,k,n,x=0;
	scanf("%d%d%d%d%d",&a,&b,&c,&d,&e);
	if(a<0){
		a=a-a-a;
		x=a*c+d;
		x=x+b*e;
	}
	else{
		a=b-a;
		x=a*e;
	}
	printf("%d\n",x);
	return 0;
}


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

int main(){
    int N;
    cin >> N;
    vector<ll> A(N),B(N);
    rep(i,N) cin >> A[i] >> B[i];
    sort(A.begin(),A.end());
    sort(B.rbegin(),B.rend());
    if(N%2==1){
        ll ans = B[N/2] - A[N/2] + 1;
        cout << ans << endl;
        return 0;
    }else{
        double L = (B[N/2-1]+B[N/2])/2.0;
        double R = (A[N/2-1]+A[N/2])/2.0;
        double ans = (L-R)/0.5 + 1;
        cout << (ll)ans << endl;
        return 0;
    }
    return 0;
}

Measured memory_bytes: 6380
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<iomanip>
#include <math.h>
using namespace std;
int main(){
    int n,k,s=0;
    cin>>n>>k;
    vector<int>a(1000000);
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    sort(a.begin(),a.end(),greater<>());
    for(int i=0;i<k;i++){
        s+=a[i];
    }
    cout<<s<<endl;
    
    return 0;
}


Measured memory_bytes: 7196
import java.io.*;
import java.text.*;
import java.util.*;
 
public class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		int N = sc.nextInt();
		int M = sc.nextInt();
		int B = sc.nextInt();
		String msg = "No";
		if (N == B && M == B) {
			msg = "Yes";
		}
		System.out.println(msg);
	}
}

Measured memory_bytes: 21844
S = input()
K = int(input())

def count(s):
    """何文字変更が必要か
    """
    a = []
    b = ''
    c = 1
    for si in s:
        if b == si:
            c += 1
        else:
            a.append(c)
            c = 1
        b = si
    a.append(c)

    r = 0
    for ai in a:
        r += ai // 2
    # print(s, a, r)
    return r

if K == 1:
    ans = count(S)
elif len(S) == 1:
    ans = K // 2
elif len(set(S)) == 1:
    ans = len(S) * K // 2
else:
    a1 = count(S*2)
    a2 = count(S*3)
    ans = a1 + (a2-a1) * (K-2)

print(ans)

# for i in range(1, 10):
#     print(i, S*i, count(S*i))


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

using namespace std;

const double PI=acos(-1);

double degree_to_rad(double deg){
	return deg/360*2*PI;
}

int main(){
	int A,B,H,M;
	scanf("%d%d%d%d",&A,&B,&H,&M);
	double h=(static_cast<double>(H)+static_cast<double>(M)/60)*2*PI/12;
	double m=static_cast<double>(M)*2*PI/60;
	double deg=abs(h-m);
	double ans=sqrt(A*A+B*B-2*A*B*cos(deg));
	printf("%.10lf",ans);
}


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

using namespace std;

int main(){
     int N;
     string s;
     cin>>N;
    
   for(int i=0;i<N;i++){
     cin>>s;
      if(s=="Y"){
        	cout<<"Four"<<endl;
            break;
      }
      else if(i+1==N){
        cout<<"Three"<<endl;
      }
   }
      
}

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


int main(){
  int n;
  int A[100];
  cin >> n;
  for (int i=0;i<n;i++){
    cin >> A[i];
  }
  sort(A, A+n);
  int base = 0;
  int cnt =0;
  for (int i=0;i<n;i++){
    if (base < A[i]){
      base = A[i];
      cnt++;
    }
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	vector<ll> a(5);
	cin >> n;
	int id = -1;
	ll mi = 1e16;
	rep(i,5){
		cin >> a[i];
		if(a[i] < mi){
			id = i;
			mi = a[i];
		}
	}
	ll ans = n/mi;
	if(n%mi == 0) ans--;
	ans += 5;
	cout << ans << endl;
	return 0;
}

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

int N;

int x[102], y[102], h[102];

int main() {
	
	cin>>N;
	rep(i, N)cin>>x[i]>>y[i]>>h[i];
	
	int t;
	rep(i, N) {
		if(h[i]>0) {
			t = i;
			break;
		}
	}
	
	bool f;
	int H;
	rep(X, 101) {
		rep(Y, 101) {
			H = h[t] + abs(X-x[t]) + abs(Y-y[t]);
			f = true;
			rep(i, N) {
				if(max(H - abs(X-x[i]) - abs(Y-y[i]), 0) != h[i]) {
					f = false;
					break;
				}
			}
			if(f) {
				cout<<X<<' '<<Y<<' '<<H<<endl;
				return 0;
			}
		}
	}
	
	return 0;
}

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

using namespace std;

int main()
{
    uint64_t hh;
    uint64_t ww;
    uint64_t ans;

    cin >> hh >> ww;
    if((hh == 1) || (ww == 1)){
        cout << 1 << endl;
        return 0;
    }

    ans = ((hh * ww) / 2) + ((hh * ww) % 2);

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import math
from math import gcd,pi,sqrt
INF = float("inf")

import sys
sys.setrecursionlimit(10**6)
import itertools
from collections import Counter,deque
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]


def main():
    n = i_input()
    a = i_list()
    ans = 0
    k = 0
    for i in range(n-2,-1,-1):
        k +=a[i+1]
        ans += a[i]*k
    print(ans%(10**9+7))

if __name__=="__main__":
    main()


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

#define pb push_back
#define fi first
#define se second
#define ll long long
#define pq priority_queue
#define mp make_pair
#define pii pair<int,int>

const int mod=1e9+7;

int lowbit(int x) {return x&(-x);}

int n;
string s;

int f[3010],sum[3010];

int main(){
	cin>>n>>s;
	f[1]=sum[1]=1;
	for (int i=2;i<=n;i++) {
		for (int j=1;j<=i;j++) {
			if (s[i-2]=='<') f[j]=sum[j-1];
			else f[j]=sum[i-1]-sum[j-1];
			if (f[j]<0) f[j]+=mod;
		}
		for (int j=1;j<=i;j++) sum[j]=(sum[j-1]+f[j])%mod;
	}
	cout<<sum[n];
	return 0;
}


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

int main(){
    int n, m;
    cin >> n >> m;
    int p[m];
    int pena=0, acnum=0, ac[n]={0}, wa[n]={0};
    string s[m];
    rep(i, m) cin >> p[i] >> s[i];

    rep(i, m) {
        if(s[i] == "AC") {
            if(ac[p[i]-1] == 0) {
                ac[p[i]-1] = 1;
                acnum++;
            }
        } else {
            if (ac[p[i]-1] == 0) {
                wa[p[i]-1]++;
            }
        }
    }

    int res = 0;

    rep(i, n) {
        if(ac[i]==1) {
            res++;
            pena += wa[i];
        }
    }

    cout << res << " " << pena << endl;

    return 0;
}

Measured memory_bytes: 6912
#include<iostream>
#include<cstring>
#include<string>
using namespace std;
string s;
bool repeat_func(int pos){
    if(pos == s.size())return true;
    if(strncmp(&s[pos],"dream",5)==0 && repeat_func(pos+5))return true;
    if(strncmp(&s[pos],"dreamer",7)==0 && repeat_func(pos+7))return true;
    if(strncmp(&s[pos],"erase",5)==0 && repeat_func(pos+5))return true;
    if(strncmp(&s[pos],"eraser",6)==0 && repeat_func(pos+6))return true;
    return false;
}
int main(void){
    cin>>s;
    if(repeat_func(0))cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}

Measured memory_bytes: 1088
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> ii;
typedef vector<int>   vi;
typedef vector<long long> vll;
typedef vector<pair<int,int> > vii;
#define ll long long
#define pb push_back
#define mp  make_pair
#define ff first
#define ss second
#define pq priority_queue
#define sf1(x) scanf("%d",&x)
#define sf2(x,y) scanf("%d %d",&x,&y)
#define sf3(x,y,z) scanf("%d %d %d",&x,&y,&z)
ll inf = (1e9) + 7;


int main(){
	int n,k;
	sf2(n,k);



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

		ans += 2*min(abs(k-aux),aux);
	}

	printf("%d\n",ans );
}	

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

int main(void) {
	int n, a, b, c, d;
	cin >> n >> a >> b >> c >> d;
	n-=1,a -= 1;b -= 1;c -= 1;d -= 1;
	string s;
	cin>>s;
	if (c < d) {
		if (c > a + 1) {
			for (int i = a;i <= c - 1;i++) {
				if (s[i] == '#') {
					if (s[i + 1] == '#') {
						cout << "No"<<endl;
						return 0;
					}
				}
			}
		}
		if (d > b + 1) {
			for (int i = b;i <= d - 1;i++) {
				if (s[i] == '#') {
					if (s[i + 1] == '#') {
						cout << "No"<<endl;
						return 0;
					}
				}
			}
		}
		cout << "Yes"<<endl;
	}
	if (c > d) {
		for (int i = a;i <= c - 1;i++) {
			if (s[i] == '#') {
				if (s[i + 1] == '#') {
					cout << "No"<<endl;
					return 0;
				}
			}
		}
		bool flag1 = false,flag2 = false;
		if (s[b - 1] == '.'&&s[b + 1] == '.')flag1 = true;
		for (int i = b;i < d;i++) {
			if (s[i] == '.') {
				if (s[i + 1] == '.') {
					if (s[i + 2] == '.') {
						flag2 = true;
						break;
					}
				}
			}
		}
		if (flag1 || flag2) cout << "Yes" <<endl;
		else cout << "No" <<endl;
	}
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
long long spow(long long x,long long y){
  long long z = 1,now = x;
  while(y){
    if(y%2) z = (z*now)%2019;
    now = (now*now)%2019;
    y >>= 1;
  }
  return z;
}
int main(){
  string s;cin >> s;
  long long n = s.size(),i,rp[2019] = {},b = 0,ans = 0;rp[0]++;
  for(i=0;i<n;i++){
    b = (b+(long long)(s[i]-'0')*spow(10,n-i))%2019;
    rp[b]++;
  }
  for(i=0;i<2019;i++) ans += rp[i]*(rp[i]-1)/2;
  cout << ans << "\n";
}

Measured memory_bytes: 3740
#include<bits/stdc++.h>
#define ll long long
#define f(i,a,b) for(ll i = a; i <= b; ++i)
#define ff(i,a,b) for(ll i = a; i < b; ++i)
#define F(i,a,b) for(ll i = a; i >= b; ++i)
#define FF(i,a,b) for(ll i = a; i > b; ++i)
#define x first
#define y second
#define X real()
#define Y imag()
using namespace std;
typedef pair<ll, ll> ii;
typedef complex<ll> P;


int main(){
	int n,k;
	cin>>n>>k;
	if(k>1){
		cout<<n-k;
	}
	else {
		cout<<0;
	}
}



Measured memory_bytes: 256
#include <iostream>
using namespace std;
long long a[200000][2];
int main(){
	int n;
	cin>>n;
	long long sum=0;
	for(int i=0;i<n;i++){
		long long b;
		cin>>b;
		sum+=b;
		a[i/2+1][i%2]=a[i/2][i%2]+b;
	}
	for(int i=0;i<n;i++){
		if(i%2==0){ 
			cout<<sum-(a[n/2][1]-a[i/2][1]+a[i/2][0])*2<<" ";
		}else{
			cout<<sum-(a[n/2+1][0]-a[i/2+1][0]+a[i/2][1])*2<<" ";
		} 
	}
	cout<<endl;
}

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

int solve(vector<int>& ht,int n,int k) {
    vector<int>dp(n,0);
    dp[0]=0;
    dp[1]=abs(ht[1]-ht[0]);
    int mn=INT_MAX;

    for(int i=2; i<n; i++) {
        for(int j=i-1; j>=i-k && j>=0; j--) {
            mn = min(mn,(dp[j]+abs(ht[i]-ht[j])));

        }
        dp[i]=mn;
        mn=INT_MAX;


    }
    return dp[n-1];
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);


    vector<int>ht;
    int n,k;
    cin>>n>>k;
    for(int i=0; i<n; i++) {
        int a;
        cin>>a;
        ht.push_back(a);
    }

    cout<<solve(ht,n,k)<<endl;



}


Measured memory_bytes: 1144
#include<cstdio>
#include<math.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<set>
#include<cstring>
#include<map>
 
 
using namespace std;
#define int long long int
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define mp make_pair
#define pb push_back
#define mod 1000000007

int A,B,C,X,Y;
int p[100010];
int q[100010];
int r[100010];
vector<pair<int,int>> all;
signed main(){
    scanf("%lld %lld %lld %lld %lld",&X,&Y,&A,&B,&C);
    rep(i,A){scanf("%lld",&p[i]);all.pb(mp(p[i],1));}
    rep(i,B){scanf("%lld",&q[i]);all.pb(mp(q[i],2));}
    rep(i,C){scanf("%lld",&r[i]);all.pb(mp(r[i],0));}
    //sort(p,p+A,greater<int>());sort(q,q+B,greater<int>());sort(r,r+C,greater<int>());
    sort(all.begin(),all.end(),greater<pair<int,int> >());
    //rep(i,all.size())printf("%lld(%lld)!",all[i].first,all[i].second);
    int i[10];i[0]=0;i[1]=0;i[2]=0;int itr=0;
    int ans=0;
    while(i[0]+i[1]+i[2]<X+Y){
        if(i[1]>=X&&all[itr].second==1){itr++;continue;}
        if(i[2]>=Y&&all[itr].second==2){itr++;continue;}
        i[all[itr].second]++;
        ans+=all[itr].first;itr++;
    }
    printf("%lld\n",ans);
    return 0;
}


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

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

  vector<int> a(n);
  rep(i, n) cin >> a.at(i);

  vector<int> balls(200000);
  rep(i, n) balls.at(a.at(i))++;
  sort(balls.begin(), balls.end());

  int kind = 0;
  rep(i, balls.size()) {
    if (balls.at(i) > 0)
      kind++;
  }

  int ans = 0;
  rep(i, balls.size()) {
    if (kind <= k) break;
    if (balls.at(i) > 0) {
      ans += balls.at(i);
      kind--;
    }
  }

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

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <iomanip>
#include <math.h>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <functional>

using namespace std;

typedef long long int ll;
typedef std::pair<int, int> pii;
typedef std::pair<ll, int> pli;
typedef std::pair<ll, ll> pll;

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

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

ll A[5];

int main()
{
	cin >> A[0] >> A[1] >> A[2];

	ll min = INF;

	REP(i, 3)
	{
		REP(j, 3)
		{
			if (i == j)continue;
			REP(k, 3)
			{
				if (i == k || j == k)continue;
				min = std::min(min, abs(A[i] - A[j]) + abs(A[j] - A[k]));
			}
		}
	}
	cout << min << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define lli long long int
using namespace std;
#define mod2 1000000007
#define MOD 1000000037
#define mod1 998244353
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 
#define INF 2e9

const int maxn = 500000 + 10;
const int mod = mod2;

void add(int &a, int b){
    a += b;
    if (a >= mod)
        a -= mod;
}

int fak[maxn];
int ifak[maxn];

int modpow(int a, int b){
    int c = 1;

    while (b){
        if (b & 1)
            c = 1LL * c * a % mod;
        a = 1LL * a * a % mod;
        b >>= 1;
    }

    return c;
}

int comb(int n, int k){
    return 1LL * fak[n] * ifak[k] % mod * ifak[n - k] % mod;
}



int main()
{
    fak[0] = 1;
    for (int i = 1; i < maxn; ++i)
        fak[i] = 1LL * fak[i-1] * i % mod;
        
    ifak[maxn-1] = modpow(fak[maxn-1], mod-2);
    
    for (int i = maxn-2; i >= 0; --i)
        ifak[i] = 1LL * ifak[i + 1] * (i+1) % mod;
    fastio;
    int n,m;
    cin >> n >> m;
    int tot=comb(m,n)*1LL*fak[n]%mod,tot1=tot;
    int ex=0;
    for(int i=1;i<=n;i++)
    {
        int a=comb(n,i)*1LL*fak[n-i]%mod;
        a=a*1LL*comb(m-i,n-i)%mod;
        a=(a+mod)%mod;
        a=a*pow(-1,i+1);
        ex=(ex*1LL+a)%mod;
        ex=(ex+mod)%mod;
    }
    tot=(tot*1LL-ex)%mod;
    tot=(tot+mod)%mod;
    tot=(tot*1LL*tot1)%mod;
    tot=(tot+mod)%mod;
    cout << tot << endl;
}

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

int main() {
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<vector<int>> ABC(N, vector<int>(3));
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < 3; j++) {
      cin >> ABC.at(i).at(j); 
    }
  }

  vector<vector<int>> DP(N + 1, vector<int>(3));
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < 3; j++) {
      for (int k = 0; k < 3; k++) {
        if (j == k) continue;
        DP.at(i + 1).at(k) = max(DP.at(i + 1).at(k), DP.at(i).at(j) + ABC.at(i).at(k));
      }
    }
  }

  cout << max({DP.at(N).at(0), DP.at(N).at(1), DP.at(N).at(2)}) << "\n";
}

Measured memory_bytes: 11264
#include<bits/stdc++.h>
#define int long long
using namespace std;
struct UnionFind{
  int par[100100],size[100100];
  UnionFind(int N){
    for(int i=0;i<N;i++)
      par[i]=i,size[i]=1;
  }
  int find(int x){
    if(par[x]==x)return x;
    int y=find(par[x]);
    par[x]=y;
    return y;
  }
  void unite(int x,int y){
    x=find(x),y=find(y);
    if(x==y)return;
    if(size[x]>=size[y])par[y]=x,size[x]+=size[y];
    else par[x]=y,size[y]+=size[x];
  }
  bool same(int x,int y){
    return find(x)==find(y);
  }
};
signed main(){
  int N,M;
  cin>>N>>M;
  vector<pair<int,int>> A(M);
  for(pair<int,int> &p:A){
    cin>>p.first>>p.second;
    p.first--,p.second--;
  }
  vector<int> B(M+1,N*(N-1)/2);
  UnionFind U(N);
  for(int i=M-1;i>=0;i--){
    pair<int,int> p=A[i];
    if(U.same(p.first,p.second))B[i]=B[i+1];
    else{
      B[i]=B[i+1]-U.size[U.find(p.first)]*U.size[U.find(p.second)];
      U.unite(p.first,p.second);
    }
  }
  for(int i=1;i<=M;i++)cout<<B[i]<<endl;
}

Measured memory_bytes: 7192