akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
using namespace std;


int main(){
    int n,k,m,i,s;
    while(cin>>n>>k>>m, n||k||m){
        vector<int> v(n);
        for(i=0;i<n;i++){
            v[i] = i+1;
        }
        k--;
        s=m-1;
        while( v.size()-1 ){
            v.erase(v.begin()+s);
            s = (s+k)%v.size();
        }
        cout << v[0] << endl;
    }
    return 0;
}

Measured memory_bytes: 1252
namespace ABC_087
{
    class Program
    {
        static void Main(string[] args)
        {
            // Coins
            var a = int.Parse(System.Console.ReadLine());
            var b = int.Parse(System.Console.ReadLine());
            var c = int.Parse(System.Console.ReadLine());
            var x = int.Parse(System.Console.ReadLine());
            System.Console.WriteLine(coins(a, b, c, x));
        }

        static private int coins(int a, int b, int c, int x)
        {
            var matches = 0;
            for (int i500 = 0; i500 <= a; i500++)
            {
                for (int i100 = 0; i100 <= b; i100++)
                {
                    for (int i50 = 0; i50 <= c; i50++)
                    {
                        var sum = 500 * i500 + 100 * i100 + 50 * i50;
                        if (sum == x)
                        {
                            matches++;
                        }
                    }
                }
            }
            return matches;

        }
    }
}


Measured memory_bytes: 13140
import functools


def check(s):
    result = 0
    sss = s

    while True:
        if len(sss) <= 1:
            break
        head = sss[0]
        tail = sss[-1]
        if head == tail:
            sss = sss[1:-1]
            continue
        if head == "x":
            result += 1
            sss = sss[1:]
            continue
        if tail == "x":
            result += 1
            sss = sss[:-1]
            continue
        return -1
    return result

def main():
    n = check(input())
    print(n)

    # total = functools.reduce(lambda a, b: a * (2 if b % 2 == 1 else 1),A)
    # print(pow(3 ,len(A)-1)*total)
    # # print(123)
    # b = [int(a) for a in input().split(" ")]
    # print(b)
    # [input() for a in range(3)]


if __name__ == "__main__":
    main()


Measured memory_bytes: 3936
#include <iostream>
#include <string>
#include <stdio.h>
#include <cmath>
#include <cfloat>
#include <algorithm>
#include <functional>
#include <numeric>
#include <vector>
using namespace std;

const double PI=acos(-1);

int main(){
    int k, n, a, aa = 0, a1 = 0, max = 0;
    cin >> k >> n;
    for(int i = 0; i < n; i++){
        cin >> a;
        if(i == 0) a1 = a;
        max = std::max(max, a - aa);
        if(i == n - 1){
            max = std::max(max, k + a1 - a);
        }
        aa = a;
    }
    cout << k - max << endl;
    return 0;
}

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

//定数
const long long MOD1=1000000007;
const long long MOD2=998244353;
const long double PI=3.1415926535897932;
const long long MAXLL=9223372036854775807;
const long long INF=2305843009213693951;
const long long dx[]={0,1,0,-1,1,-1,1,-1};
const long long dy[]={1,0,-1,0,1,1,-1,-1};

//型名省略
#define ll long long
#define ull unsigned long long
#define ld long double
#define uld unsigned long double
#define pll pair<long long,long long>
#define tll(n) array<long long,(int)(n)>
#define pcc pair<char,char>
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vp vector<pair<long long,long long>>
#define vt(n) vector<array<long long,(int)(n)>>
#define umap unordered_map
#define uset unordered_set
#define Lqueue priority_queue<long long>
#define Squeue priority_queue<long long,vector<long long>,greater<long long>>
#define Fi first
#define Se second
#define mp make_pair
#define eb emplace_back

//マクロ
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define rbf(a,x) for(auto& a:x)
#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s);i<(long long)(n);i++)
#define bitrep(i,s,n) for(long long i=(s);i<(1LL<<(n));i++)
#define Maxe(x) *max_element((x).begin(),(x).end())
#define Mine(x) *min_element((x).begin(),(x).end())
#define Size(x) ((long long)(x).size())
#define lin(s) getline(cin,(s))
#define Ssort(v) sort((v).begin(),(v).end(),[](auto &left,auto &right){return left.second<right.second;})

//Yes,No
void Yes(bool a){cout<<(a?"Yes":"No")<<endl;}
//YES.NO
void YES(bool a){cout<<(a?"YES":"NO")<<endl;}

//MAX,MIN
template<class T,class U> auto max(T a,U b){return a>b?a:b;}
template<class T,class U> auto min(T a,U b){return a<b?a:b;}

//最大公約数,最小公倍数
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a,long long b){return a/gcd(a,b)*b;}

//累乗
template<typename t>
constexpr t mypow(t a,long long b){
    if(b==0)return 1;
    if(a==0)return 0;
    t x=1;
    while(b>0){
        if(b&1LL)x*=a;
        a*=a;
        b>>=1LL;
        }
    return x;
}
#define pow mypow

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

//組み合わせ O(r)
template<typename t>
constexpr t nCr(t n,long long r){
    if(r==0)return 1;
    if(n==0)return 0;
    if(n<r)return 0;
    t x=1;
    for(long long i=1;i<=r;i++){
        x*=n-i+1;
        x/=i;
    }
    return x;
}

//main関数
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll n,k;
    cin>>n>>k;
    if(n%k==0)cout<<0<<endl;
    else cout<<1<<endl;
}

Measured memory_bytes: 3624
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner stdIn = new Scanner(System.in);
		int S = stdIn.nextInt();
		int ans = 0;
		int mod = 1000000007;
		ArrayList<Integer> A = new ArrayList<Integer>();
		A.add(0);
		A.add(0);
		A.add(0);
		A.add(1);
		A.add(1);
		A.add(1);
		if(3 <= S) {
			for(int i = 6; i <= S; i ++) {
				A.add((A.get(i - 1) % mod + A.get(i - 3)) % mod);
			}
			ans = A.get(S);
		}
		System.out.println(ans);
	}
}

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

using namespace std;

int N;
long long X, H[51], P[51];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    H[0] = 1;
    P[0] = 1;
    for (int i = 1; i <= 50; i++) {
        H[i] = 3 + 2 * H[i - 1];
        P[i] = 1 + 2 * P[i - 1];
    }
    
    cin >> N >> X;
    long long res = 0;
    
    while(N > 0 && X > 0) {
        if (X >= 2 + 2 * H[N - 1]) {
            res += 1 + 2 * P[N - 1];
            X = 0;
            break;
        }
        if (X >= 2 + H[N - 1]) {
            res += 1 + P[N - 1];
            X -= 2 + H[N - 1];
        } else if (X == 1 + H[N - 1]) {
            res += P[N - 1];
            X -= 1 + H[N - 1];
        } else {
            X--;
        }
        N--;
    }
    
    if (X) {
        res++;
    }
    
    cout << res << endl;

}



Measured memory_bytes: 256
from collections import defaultdict
import bisect
S = input()
T = input()

d = defaultdict(list)

for i, s in enumerate(S):
    d[s].append(i)

ans = 0
now = -1
for t in T:
    arr = d[t]
    if len(arr) == 0:
        print(-1)
        exit()
    idx = bisect.bisect_right(arr, now) # leftにすると、同じ文字を2連続探索するときにバグる
    if idx == len(arr):
        ans += 1
        now = arr[0]
    else:
        now = arr[idx]
print(ans * len(S) + now + 1)

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

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

int main(){
	int t;	cin>>t;
	while(t--){
		ll a,b,c,d;	cin>>a>>b>>c>>d;
		if(a<b){
			cout<<"No\n";	continue;
		}
		if(d<b){
			cout<<"No\n";	continue;
		}
		ll t1=gcd(b,d);
		ll t2=(a-b)/t1;	t2++;
		if(t2*t1 < (a-c))	cout<<"No\n";
		else	cout<<"Yes\n";
	}
	return 0;
}

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

int main(){
  int n;
  cin >> n;
  vector<char>vec(n);
  for (int i = 0 ; i < n; i++){
    cin >> vec.at(i);
  }
  vector<int>control(n);
  for (int i = 1; i < n ; i++){
    if (vec.at(i) == 'E'){
      control.at(0)++;
    }
  }
  for (int j = 0 ; j< n-1;j++){
    control.at(j+1) += control.at(j);
    if (vec.at(j) == 'W')
      control.at(j+1)++ ;
    if (vec.at(j+1) == 'E')
      control.at(j+1)--;
  }
  
        
  sort(control.begin(),control.end());
  cout << control.at(0);
}

      
     
    
  
 


Measured memory_bytes: 1664
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

// 内部変数 - テスト用
#ifdef D_TEST
	static int siRes;
	static FILE *szpFpT, *szpFpA;
#endif

// 実行メイン
int
fMain(
	int piTNo					// <I> テスト番号 1～
)
{
	char lc1Buf[1024], lc1Out[1024];

	// テストファイルオープン
#ifdef D_TEST
	sprintf(lc1Buf, ".\\Test\\T%d.txt", piTNo);
	szpFpT = fopen(lc1Buf, "r");
	sprintf(lc1Buf, ".\\Test\\A%d.txt", piTNo);
	szpFpA = fopen(lc1Buf, "r");
	siRes = 0;
#endif

	// S数・C数の取得
	long long llSCnt, llCCnt;
#ifdef D_TEST
	fgets(lc1Buf, sizeof(lc1Buf), szpFpT);
#else
	fgets(lc1Buf, sizeof(lc1Buf), stdin);
#endif
	sscanf(lc1Buf, "%lld%lld", &llSCnt, &llCCnt);

	// S数の補正
	if (llSCnt * 2 > llCCnt) {
		llSCnt = llCCnt / 2;
	}

	// SCCの数
	long long llCnt = llSCnt;

	// Cの残数
	llCCnt -= llSCnt * 2;

	// Cの残数を加算
	llCnt += llCCnt / 4;

	// 結果セット
	sprintf(lc1Out, "%lld\n", llCnt);

	// 結果表示
#ifdef D_TEST
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, lc1Out)) {
		siRes = -1;
	}
#else
	printf("%s", lc1Out);
#endif

	// テストファイルクローズ
#ifdef D_TEST
	fclose(szpFpT);
	fclose(szpFpA);
#endif

	// テスト結果
#ifdef D_TEST
	if (siRes == 0) {
		printf("OK %d\n", piTNo);
	}
	else {
		printf("NG %d\n", piTNo);
	}
#endif

	return 0;
}

int
main()
{

#ifdef D_TEST
	int i;
	for (i = D_TEST_SNO; i <= D_TEST_ENO; i++) {
		fMain(i);
	}
#else
	fMain(0);
#endif

	return 0;
}



Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <set>
#include <map>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <cmath>

using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;

int h,w;
char mm[101][101];

int main(int argc,char** argv) {
	string s;
	cin >> h >> w;
	set<int> skipx,skipy;
	for(int y = 0;y < h;y++) {
		cin >> s;
		bool ad = true;
		for(int x = 0;x < w;x++) {
			mm[x][y] = s[x];
		}
	}
	for(int x = 0;x < w;x++){
			bool ad = true;
			for(int y = 0;y < h;y++) {
				if(mm[x][y] != '.') ad = false;
			}
			if(ad) skipx.insert(x);
		}
	for(int y = 0;y < h;y++){
		bool ad = true;
		for(int x = 0;x < w;x++) {
			if(mm[x][y] != '.') ad = false;
		}
		if(ad) skipy.insert(y);
	}
	for(int y = 0;y < h;y++) {
		if(skipy.find(y) != skipy.end()) continue;
		for(int x = 0;x < w;x++) {
			if(skipx.find(x) != skipx.end()) continue;
			cout << mm[x][y];
		}
		cout << endl;
	}
}


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

int main()
{
    int A,B;
    cin >> A >> B;
    cout << A*B << endl;
    return 0;
}

Measured memory_bytes: 3636
#include<cstdio>

int main(void){

int c=0,n,m,i,j;
//nyuuryoku
scanf("%d%d",&n,&m);
int nm;
nm=n*m;
int a[nm];
int b[m];
for(i=0;i<nm;i++){
	scanf("%d",&a[i]);
};
for(i=0;i<m;i++){
	scanf("%d",&b[i]);
};
//shuturyoku
for(i=0;i<n;i++){
	for(j=0;j<m;j++){
		c=c+a[i*m+j]*b[j];
		
	};
	printf("%d\n",c);
	c=0;
};
return 0;
}

Measured memory_bytes: 2744
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric>

#define ull unsigned long long
#define ul unsigned long
#define ll long long
#define size_t long long
// std::sort(&a[0], &a[4], [](auto& x, auto& y){return x[0] < y[0];});
//accumulate(&arr2[n], &arr2[m-1], 0);
using namespace std;

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

  ll n;
  ll d;
  std::cin >> n >> d;

  double x[n][d] = {};

  for (size_t i = 0; i < n; i++) {
    for (size_t j = 0; j < d; j++) {
      std::cin >> x[i][j];
    }
  }
  int cnt = 0;
  for (size_t i = 0; i < n - 1; i++) {
    for (size_t j = i + 1; j < n; j++) {
      double sum = 0;
      for (size_t k = 0; k < d; k++) {
        sum += (x[i][k] - x[j][k])*(x[i][k] - x[j][k]);
      }
      if(sqrt(sum) == (int)sqrt(sum)){
        cnt++;
      }
    }
  }

  std::cout << cnt << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cctype>

#include <algorithm>
#include <random>
#include <bitset>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <vector>
#include <chrono>
#include <iostream>
#include <limits>
#include <numeric>

#define LOG(FMT...) fprintf(stderr, FMT)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

template <class T>
istream& operator>>(istream& is, vector<T>& v) {
  for (T& x : v)
    is >> x;
  return is;
}

template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
  if (!v.empty()) {
    os << v.front();
    for (int i = 1; i < v.size(); ++i)
      os << ' ' << v[i];
  }
  return os;
}

int main() {
#ifdef LBT
  freopen("test.in", "r", stdin);
  int nol_cl = clock();
#endif
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  function<vector<int>(int)> getPrimes = [&](int x) {
    vector<int> ret;
    vector<bool> vis(x + 1);
    for (int k = 2; k <= x; ++k)
      if (!vis[k]) {
        ret.push_back(k);
        for (int j = k; j <= x; j += k)
          vis[j] = true;
      }
    return ret;
  };
  vector<int> pr = getPrimes(2200);
  vector<ll> pr3;
  for (int p : pr) pr3.push_back(p * (ll)p * p);

  int N;
  cin >> N;
  map<ll, int> cnt;
  int ans = 0;
  ll mx = 0;
  while (N--) {
    ll x;
    cin >> x;
    for (ll v : pr3)
      while (x % v == 0)
        x /= v;
    if (x == 1)
      ans = 1;
    else
      ++cnt[x];
    mx = max(mx, x);
  }
  int searchLimit = 1 + pow(mx, 1. / 3);
  function<int(ll)> pSQRT = [&](ll x) {
    int rt = sqrt(x);
    while (rt * (ll)rt < x) ++rt;
    while (rt * (ll)rt > x) --rt;
    return rt * (ll)rt == x ? rt : -1;
  };
  function<ll(ll)> dual = [&](ll x) {
    int cur;
    for (int k = 1; k <= searchLimit; ++k)
      if (x % k == 0 && (cur = pSQRT(x / k)) != -1)
        return k * k * (ll)cur;
    for (int k = searchLimit; k; --k)
      if (x % k == 0 && x / k % k == 0) {
        ll tmp = x / (k * k);
        if (tmp * k > mx / tmp)
          return -1LL;
        return tmp * tmp * k;
      }
    return -1LL;
  };

  while (!cnt.empty()) {
    ll x;
    int a;
    tie(x, a) = *cnt.begin();
    cnt.erase(cnt.begin());
    ll du = dual(x);
    ans += max(cnt[du], a);
    cnt.erase(du);
  }
  cout << ans;

#ifdef LBT
  LOG("Time: %dms\n", int ((clock()
          -nol_cl) / (double)CLOCKS_PER_SEC * 1000));
#endif
  return 0;
}


Measured memory_bytes: 8576
import math

x = int(input())
y = 0

if x==2: #2だけは例外
  print(2)
  
else: #xの素数判定
  while y == 0: #素数でない間は続ける
    for k in range(2, int(math.sqrt(x)) + 1): #2以上ルートn以下で割り切れるか調べる
      if x % k == 0: #もし割り切れたら、
        x = x + 1 #素数ではないので、xを+1して、
        break #for文を抜けてwhileに戻る
      if k == int(math.sqrt(x)):
        y = 1
  print(x)

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

const vector<int> dy = {1, -1, 0, 0};
const vector<int> dx = {0, 0, 1, -1};

int compress(vector<int> &x1, vector<int> &x2, int w) {
    int n = x1.size();
    vector<int> X;
    for (int i = 0; i < n; ++i) {
        for (int d = -1; d <= 1; ++d) {
            int tx1 = x1.at(i) + d;
            int tx2 = x2.at(i) + d;
            if (0 <= tx1 && tx1 < w) X.push_back(tx1);
            if (0 <= tx2 && tx2 < w) X.push_back(tx2);
        }
    }
    sort(X.begin(), X.end());
    X.erase(unique(X.begin(), X.end()), X.end());
    for (int i = 0; i < n; ++i) {
        x1.at(i) = lower_bound(X.begin(), X.end(), x1.at(i)) - X.begin();
        x2.at(i) = lower_bound(X.begin(), X.end(), x2.at(i)) - X.begin();
    }
    return X.size();
}

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

    while (true) {
        int w, h;
        cin >> w >> h;
        if (w == 0 && h == 0) break;
        int n;
        cin >> n;
        vector<int> x1(n), y1(n), x2(n), y2(n);
        for (int i = 0; i < n; ++i) {
            cin >> x1.at(i) >> y1.at(i);
            cin >> x2.at(i) >> y2.at(i);
            x2.at(i)--;
            y2.at(i)--;
        }
        w = compress(x1, x2, w);
        h = compress(y1, y2, h);

        vector<vector<int> > field(h, vector<int>(w, 0));
        for (int i = 0; i < n; ++i) {
            for (int y = y1.at(i); y <= y2.at(i); ++y) {
                for (int x = x1.at(i); x <= x2.at(i); ++x) {
                    field.at(y).at(x) = 1;
                }
            }
        }
        int ans = 0;
        for (int y = 0; y < h; ++y) {
            for (int x = 0; x < w; ++x) {
                if (field.at(y).at(x)) continue;
                ans++;
                queue<pair<int, int> > que;
                que.push(make_pair(y, x));
                while (!que.empty()) {
                    auto p = que.front();
                    que.pop();
                    for (int i = 0; i < 4; ++i) {
                        int ny = p.first + dy.at(i);
                        int nx = p.second + dx.at(i);
                        if (ny < 0 || h <= ny) continue;
                        if (nx < 0 || w <= nx) continue;
                        if (field.at(ny).at(nx)) continue;
                        field.at(ny).at(nx) = 1;
                        que.push(make_pair(ny, nx));
                    }
                }
            }
        }
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 9716
from collections import Counter
def i(): return int(input())
def l(): return list(map(int,input().split()))
N = i();A = l();A.sort();dp = [1]*(10**6+1);C = Counter(A);ans = 0
for a,b in C.items():
    if b != 1:dp[a] = 0
    elif dp[a]:ans += 1
    for j in range(a,10**6+1,a):dp[j] = 0
print(ans)

Measured memory_bytes: 43820
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef vector<int> vei;
typedef vector<string> ves;
typedef vector<vector<int>> ve_vei;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define fs first
#define sc second
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
 
int main() {
	//cout.precision(10);
	cin.tie(0);
	ios::sync_with_stdio(false);

    int a, b; cin >> a >> b;
    cout << (b- a - 1) * (b - a) / 2 - a << endl;
}

Measured memory_bytes: 256
S = input()
N = len(S)


def is_kaibun(s):
    return "".join(list(reversed(s))) == s


def is_strong_kaibun(s):
    return is_kaibun(s) and is_kaibun(s[:int(N / 2)]) and is_kaibun(s[int(N / 2) + 1:])


result = "Yes" if is_strong_kaibun(S) else "No"
print(result)

Measured memory_bytes: 3060
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long lli;
int main()
{
	int n, m, k, a, i, ans=0;
    int count[31]={0};
    cin >> n >> m;
    for(i=0; i<n; i++) {
        cin >> k;
        for(int j=0; j<k; j++) {
            cin >> a;
            count[a]++;
        }
    }
    for(i=1; i<=m; i++) {
        if(count[i]==n)ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, B):
    B.append(sys.maxsize)
    ans = 0
    for i in range(N):
        ans += min(B[i-1], B[i])
    return ans



def main():
    N = read_int()
    B = read_int_n()
    print(slv(N, B))


if __name__ == '__main__':
    main()


Measured memory_bytes: 6860
#include <bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define Mod 1000000007
#define ll long long
#define dd double
#define pb push_back
#define ff first
#define ss second
#define Mp make_pair
#define INF 999999999999999999
#define NN (ll)(1e6+5)
int mod(string s,int a) 
{ 
    int ans=0; 
    for (int i=0;i<s.length();i++) 
         ans=(ans*10+(int)s[i]-'0')%a; 
    return ans; 
}
ll min(ll x,ll y){if(x<y) return x;return y;}
ll max(ll x,ll y){if(x>y) return x;return y;}
ll power(ll x,unsigned ll y) 
{ 
    if (y==0) 
        return 1; 
    else if (y%2==0) 
        return power(x,y/2)*power(x,y/2); 
    else
        return x*power(x,y/2)*power(x,y/2); 
}
ll hcf(ll a,ll b) 
{ 
    if(b==0) 
        return a; 
    return hcf(b,a%b);  
}
int main()
{
   fio;
   /*#ifndef ONLINE_JUDGE 
    	freopen("input.txt", "r", stdin); 
    	freopen("output.txt", "w", stdout); 
    	freopen("error.txt", "w", stderr); 
   #endif*/
   ll TT=1;
   //cin>>TT;
   while(TT--)
   {    
       ll n,m,i,j,x,y,ans=0;
       cin>>n>>m;
       vector <ll> h(n+1);
       for(i=1;i<=n;i++)
        cin>>h[i];
       vector <ll> v[n+1];
       for(i=0;i<m;i++)
       {
           cin>>x>>y;
           v[x].pb(y);
           v[y].pb(x);
       } 
       for(i=1;i<=n;i++)
       {
           ll c=0;
           for(auto u:v[i])
            if(h[i]<=h[u])
             c++;
           if(!c)
           ans++;  
       }
       cout<<ans<<"\n";
   }
}

Measured memory_bytes: 9800
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<map>
#include<functional>
#include<set>
#include<numeric>

#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define rep(i,n) FOR(i,0LL,n)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define rrep(i,n) RFOR(i,0LL,n)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define COUNT(a,x)  upper_bound(all(a), x) - lower_bound(all(a), x)
#define MCOUNT(a,x,y) upper_bound(all(a), y) - lower_bound(all(a), x)
#define UNIQUE(a) sort(all(a)); a.erase(unique(all(a)), a.end())
#define SUM(a) accumulate(all(a),0LL)
#define scan(x) scanf("%lld",&x)
#define pb push_back
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef map<ll, ll> MAP;
typedef set<ll> SET;
typedef double D;
const ll inf = 2222222222222222222LL;
const ll mod = 1000000007LL;
const D pi = acos(-1);
const D eps = 1e-10;

ll n = 0, m = 0, ans = 0, cnt = 0, tmp = 0, ma = -inf, mi = inf;
string s;
bool ok, flag;
ll dx[5] = { 1,-1,0,0,0 }, dy[5] = { 0,0,1,-1,0 };
ll ddx[9] = { 1,-1,0,0,1,1,-1,-1,0 }, ddy[9] = { 0,0,1,-1,1,-1,1,-1,0 };
#pragma endregion
#define MAX 111111


int main(void) {
  cin >> n >> m;
  ll a = max(n - m, m);
  ll b = min(n - m, m);

  while (b) {
	ans += 3 * b * (a / b);
	tmp = a % b;
	a = b;
	b = tmp;
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
  int n;
  cin>> n;
  while(n!=0){
    int i,j,k;
    string str;
    int mp[86401]={};
    for(i=0;i<n;i++){
      int st=0,et=0;
      cin >> str;
      st=((str[0]-'0')*10+str[1]-'0')*60*60
	+((str[3]-'0')*10+str[4]-'0')*60+((str[6]-'0')*10+str[7]-'0');
      cin >> str;
      et=((str[0]-'0')*10+str[1]-'0')*60*60
	+((str[3]-'0')*10+str[4]-'0')*60+((str[6]-'0')*10+str[7]-'0');
      for(j=st;j<et;j++) mp[j]++;
    }
    int m=0,b;
    for(i=0;i<86401;i++) if(m<mp[i]) m=mp[i];
    cout << m << endl;
    cin >> n;
  }
  return 0;
}

Measured memory_bytes: 1552
n,m = list(map(int,input().split()))
L = set(int(input()) for _ in range(m))
dp = [0]*(n+1)
mod = 10**9+7
dp[0] = 1
for i in range(n):
    if i + 1 not in L:
        dp[i+1] += dp[i]
        dp[i+1] %= mod
    if i+2 not in L and i+2 < n+1 :
        dp[i+2] += dp[i]
        dp[i+2] %= mod
print(dp[n])

Measured memory_bytes: 11884
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N;
  cin >>N;
  int sum=0;
  vector<int> s(N);
  for(int i=0;i<N;i++){
    cin >>s.at(i);
  }
  sort(s.begin(),s.end());
  int x=10;
  int flag=0;
  for(int i=0;i<N;i++){
    sum += s.at(i);
    if(s.at(i)%10 != 0 && flag != 1){
      x=s.at(i);
      flag = 1;
    }
  }
  if(x%10 == 0) cout << 0 << endl;
  else if(sum%10 == 0) cout << sum-x << endl;
  else cout << sum<< endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
using namespace std;
using ll = long long;
#define pi 3.1415926

int a[3];

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    int br=0;
    if(b/a > c)
        cout << c;
    else 
        cout << b/a;
}
	


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int i = 0;
	int count = 0;
	char S[101];
	scanf("%s", S);
	while(S[i] !='\0'){
		if(i%2==0){
			if(S[i]=='R'||S[i]=='U'||S[i]=='D'){
				count = count +0;
				}
			else {count++;}}
			
		else if(i%2==1){
			if(S[i]=='L'||S[i]=='U'||S[i]=='D'){
				count = count + 0;}
			else {count++;}}
			i++;
	}
	if(count == 0){
		printf("Yes");}
    else if(count != 0){printf("No");}
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define dup(x,y) (((x)+(y)-1)/(y))
#define v(T) vector<T>
#define vv(T) v(v(T))
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pii> vp;
inline int getInt() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MX = 200005;
#define M 1000000007
//---------------------------------------------------------------
#define fastio cin.tie(nullptr); std::ios::sync_with_stdio(false);
#define myio ifstream iofi; if(argc>1){iofi.open(argv[1]); std::cin.rdbuf(iofi.rdbuf());}
#define myloopset int loop = 1; if(argc>2) loop =stoi(argv[2]); rep(i,loop)

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

void Main(){
  string s;
  cin>>s;
  reverse(rng(s));
  string t[4] = {"eraser","dreamer","dream","erase"};
  rep(i,4) reverse(rng(t[i]));
  while(s.length()>4){
    bool f=false;
    rep(i,4){
      if(s.find(t[i]) == 0){
        s.erase(s.begin(),s.begin()+t[i].length());        
        f = true;
        break;
      }
    }
    if(!f) break;
  }
  std::cout << ((s.length()==0)? "YES":"NO") << std::endl;
} int main(int argc,char** argv)
{fastio; myio; myloopset Main();}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define reg register
#define ll long long
inline ll read()
{
	ll x=0,w=0;char ch=getchar();
	while(!isdigit(ch))w|=ch=='-',ch=getchar();
	while(isdigit(ch))x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
	return w?-x:x;
}
ll k,ans;int len;
char s[105],zhan[105];
int a[105],top;
int main()
{
    scanf("%s%lld",s+1,&k);len=strlen(s+1);
    reg int i,gs=1;zhan[top=1]=s[1];
    for(i=2;i<=len;++i)
    {
        if(s[i]!=s[i-1])
            a[top]=gs,gs=1,zhan[++top]=s[i];
        else gs++;
    }a[top]=gs;
    if(top==1)
    {
        ans=1ll*len*k/2;
        cout<<ans<<"\n";
        return 0;
    }
    if(s[1]!=s[len])
    {
        for(i=1;i<=top;++i)
            ans+=a[i]/2;
        ans=1ll*ans*k;cout<<ans<<"\n";
    }
    else
    {
        for(i=2;i<top;++i)
            ans+=a[i]/2;
        ans=1ll*ans*k;ans+=a[1]/2;ans+=a[top]/2;
        ans+=((a[1]+a[top])/2)*(k-1);cout<<ans<<"\n";
    }
	return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"math"
)

func main() {
	var n, k int64
	fmt.Scan(&n, &k)

	ret := n % k
	for {
		temp := int64(math.Abs(float64(ret - k)))
		if ret > temp {
			ret = temp
		}
		if ret-k < 0 {
			break
		}
	}
	fmt.Println(ret)
}


Measured memory_bytes: 512
#include <bits/stdc++.h> 
using namespace std;
int dp[1000000];
int fun(int *a,int i,int n){
   if(i>=n-1){
       return 0;
   } 
   if(dp[i]!=-1){
       return dp[i];
   }
   int ans1=INT_MAX,ans2=INT_MAX;
   
   ans1=abs(a[i]-a[i+1])+fun(a,i+1,n);
 
   if(i+2<n){
  ans2=abs(a[i]-a[i+2])+fun(a,i+2,n);
   }
//cout<<ans1<<ans2<<endl;
  return dp[i]=min(ans1,ans2);
}
int main() 
{ 
int n;
cin>>n;
int a[n];
for(int i=0;i<n;i++){
    cin>>a[i];
}
memset(dp,-1,sizeof(dp));
cout<<fun(a,0,n);
    
    
    
}

Measured memory_bytes: 12288
# -*- coding: utf-8 -*-
 
import math
import itertools
import sys
import copy
 
# 入力
#A, B, C, D = map(int, input().split())
#L = list(map(int, input().split()))
#S = list(str(input()))
#N = int(input())
#S = str(input())
T, X= map(int, input().split())

print (T/X)


Measured memory_bytes: 38256
module S = Set.Make (struct type t = int let compare = compare end);;
let () =
    let main () =
        let n = read_line () |> int_of_string in
        let s = read_line () in
        let letter = Array.make 26 S.empty in
        let ss = Array.init n (fun i ->
            let code = int_of_char s.[i] - 97 in
            letter.(code) <- S.add (i + 1) letter.(code);
            code
        )
        in
        let q = read_line () |> int_of_string in
        for i = 1 to q do
            Scanf.sscanf (read_line ()) "%d %d %s" (fun command a b ->
                if command = 1 then (
                    let c = ss.(a - 1) in
                    letter.(c) <- S.remove a letter.(c);
                    let c = int_of_char b.[0] - 97 in
                    letter.(c) <- S.add a letter.(c);
                    ss.(a - 1) <- c;
                ) else (
                    let r = int_of_string b in
                    let rec loop i acc =
                        if i = 26 then acc else
                            let _,_,s = S.split (a - 1) letter.(i) in
                            let s,_,_ = S.split (r + 1) s in
                            let acc = if S.is_empty s then acc else acc + 1 in
                            loop (i + 1) acc
                    in
                    loop 0 0 |> Printf.printf "%d\n"
                )
            )
        done
    in
    main ()

Measured memory_bytes: 40320
#include <bits/stdc++.h>
#define st first
#define nd second

using namespace std;

void debug_out() { cerr << endl; }
template<class T> ostream& prnt(ostream& out, T v) { out << v.size() << '\n'; for(auto e : v) out << e << ' '; return out;}
template<class T> ostream& operator<<(ostream& out, vector <T> v) { return prnt(out, v); }
template<class T> ostream& operator<<(ostream& out, set <T> v) { return prnt(out, v); }
template<class T1, class T2> ostream& operator<<(ostream& out, map <T1, T2> v) { return prnt(out, v); }
template<class T1, class T2> ostream& operator<<(ostream& out, pair<T1, T2> p) { return out << '(' << p.st << ' ' << p.nd << ')'; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << " " << H; debug_out(T...);}

#define dbg(...) cerr << #__VA_ARGS__ << " ->", debug_out(__VA_ARGS__)
#define dbg_v(x, n) do{cerr<<#x"[]: ";for(int _=0;_<n;++_)cerr<<x[_]<<" ";cerr<<'\n';}while(0)
#define dbg_ok cerr<<"OK!\n"

const int N = 505;
const int X = 10000;
int n, a[N][N], m , w, h;

int main() {
	ios_base::sync_with_stdio(false);

	cin >> n >> m >> h >> w;

	if(n % h == 0 && m % w == 0)
		return cout << "No\n", 0;

	cout << "Yes\n";

	if(n % h == 0) {
		for(int i = 1; i <= n; i++) 
			for(int j = 1; j <= m; j++)
				if(j % w == 0)
					a[i][j] = -X * (w - 1) - 1;
				else 
					a[i][j] = X;
	} else {

		for(int i = 1; i <= n; i++) 
			for(int j = 1; j <= m; j++)
				if(i % h == 0)
					a[i][j] = -X * (h - 1) - 1;
				else 
					a[i][j] = X;
	}

	for(int i= 1; i <= n; i++)
		for(int j = 1; j <= m; j++)
			cout << a[i][j] << " \n"[j == m];
}	

	

Measured memory_bytes: 2816
from heapq import heapify,heappush, heappop

N=input()
A=map( int, raw_input().split() ) 

q=A[:N]
heapify(q)
q_sum=sum(q)

B=[ float("-inf") for i in range(3*N)]
B[N-1]=q_sum

for i in range(N,2*N):
	x=A[i]
	if x>q[0]:
		tmp=heappop(q)
		q_sum-=tmp
		q_sum+=x
		heappush(q,x)
	B[i]=q_sum

q=map(lambda x: x*-1, A[2*N:] )
heapify(q)

q_sum=sum(q)*-1
B[2*N-1]-=q_sum

for i in range(2*N-1,N-1,-1):
	x=A[i]*-1
	if q[0]<x:
		tmp=heappop(q)
		q_sum-=tmp*-1
		q_sum+=x*-1
		heappush(q,x)
	B[i-1]-=q_sum

print max(B)

Measured memory_bytes: 72528
n,k=gets.chomp.split.map(&:to_i)
r,s,p=gets.chomp.split.map(&:to_i)
t=gets.chomp.split("")
tt=[]
win={'r' => 'p', 'p' => 's', 's' => 'r'}
sc={'r' => r, 'p' => p, 's' => s}
ans=0
t.each_with_index do |v,i|
  if i < k
    ans += sc[win[v]]
    tt << win[v]
  else
    if win[v] == tt[i-k]
      tt << 'q'
    else
      ans += sc[win[v]]
      tt << win[v]
    end
  end
end
puts ans

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

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

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

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

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

using namespace std;

/* Some Libraries */

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

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,k; cin>>n>>k;
    ll ans=0;
    FOR(b,k+1,n){
        ans+=n/b*(b-k);
        ans+=max(0,(n%b)-max(0,k-1));
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
A = input()
N=len(str(A))
for i in range(N-2):
  if i ==0:
    B=A[i:i+3]
    V=int(B)
  else:
    B=int(A[i:i+3])
    if abs(753-B)<=abs(753-V):
      V=B
print(abs(V-753))
    
    

Measured memory_bytes: 9112
if __name__ == '__main__':
    n, q = map(int, input().split())
    s = input()
    acc = [0] * (n + 1)
    for i in range(1, n):
        acc[i + 1] = acc[i]
        if s[i - 1:i + 1] == 'AC':
            acc[i + 1] += 1
    for l, r in (tuple(int(s) for s in input().split()) for _ in range(q)):
        print(acc[r] - acc[l])


Measured memory_bytes: 8132
/*
power code taken from geeks for geeks
*/

#include <bits/stdc++.h>
#define MODD 1000000007LL
#define MAX_SIZE 100000000
#define MAX_N 200001
using namespace std;
typedef long long ll;

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

ll modd(ll a){if(a<0LL) return a*-1LL;return a;}
double modd(double a){if(a<0.0) return a*-1.0;return a;}

ll modulo(ll a){return a % MODD; }

ll power(ll k, ll p){
    if (p == 0)
        return 1LL;
 
    ll P = power(k, p/2LL);
    P = (P * P) % MODD;
 
    if (p % 2 == 1)
        P = (P * k) % MODD;
 
    return P;
}

void swap(ll& s1, ll &s2){
    ll temp=s1;
    s1=s2;
    s2=temp;
}

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

struct p_str{
    ll a,b;
};

void solve(){
    ll n;
    cin>>n;
    set<string> st;
    while(n>0){
        n--;
        string s;
        cin>>s;
        st.insert(s);
    }
    cout<<st.size()<<endl;
}


int main(){



    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    

    ll t=1;
    
    // cin>>t;
    
    while(t--){
        solve();
    }
    
    return 0;
}


Measured memory_bytes: 19244
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T> using vec = std::vector<T>;

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

    vec<ll> a(n);
    rep(i, n) {
        cin >> a[i];
    }

    ll ans0 = 0;
    ll sm   = 0;
    rep(i, n) {
        sm += a[i];
        if (i % 2 == 0 && sm <= 0) {
            ans0 += (abs(sm) + 1);
            sm = 1;
        } else if (i % 2 == 1 && sm >= 0) {
            ans0 += (abs(sm) + 1);
            sm = -1;
        }
    }

    ll ans1 = 0;
    ll sm1  = 0;
    rep(i, n) {
        sm1 += a[i];
        if (i % 2 == 0 && sm1 >= 0) {
            ans1 += (abs(sm1) + 1);
            sm1 = -1;
        } else if (i % 2 == 1 && sm1 <= 0) {
            ans1 += (abs(sm1) + 1);
            sm1 = 1;
        }
    }
    cout << min(ans0, ans1) << endl;
}


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

int main() {
    int N;
    cin >> N;
    vector<int> a(N);
    for (int i = 0; i < N; i++) {
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    double ans = a[0];
    for (int i = 1; i < N; i++){
        ans = (ans + a[i]) / 2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
int main() {
	int n, i;
	double s, a2, a;
	while (true) {
		scanf("%d", &n);
		if (n == 0)break;
		a = 0;
		a2 = 0;
		for (i = 0; i < n; i++) {
			scanf("%lf", &s);
			a += s;
			a2 += s*s;
		}
		printf("%f\n", std::sqrt(a2/n - a/n*a/n));
	}
	return 0;
}


Measured memory_bytes: 2748
// This code writed by chtholly_micromaker(MicroMaker)
#include <bits/stdc++.h>
#define reg register
#define int long long
using namespace std;
template <class t> inline void rd(t &s)
{
	s=0;
	reg char c=getchar();
	while(!isdigit(c))
		c=getchar();
	while(isdigit(c))
		s=(s<<3)+(s<<1)+(c^48),c=getchar();
	return;
}
int a[100050];
signed main(void)
{
	ios::sync_with_stdio(false);cin.tie(0);
	int n;cin>>n;
	reg int ans=0,cnt=0;
	for(int i=1;i<=n;++i)
		cin>>a[i];
	for(int i=1;i<n;++i)
		if(a[i]>=a[i+1])
			++cnt;
		else
			ans=max(ans,cnt),cnt=0;
	cout<<max(ans,cnt)<<endl;
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N=2*1e5+100;
int n,f,z,k,a[N],b[N],w,zero;
bool check(int mid)
{
	int cnt=0;
	if (mid==0)
	  cnt+=z*f+zero;
	if (mid<0)
	{
		for (int i=1;i<=f;i++)
		{
			int aim=(mid%a[i]==0)?mid/a[i]:(mid/a[i]+1);
			int pos=lower_bound(b+1,b+1+z,aim)-b;
			cnt+=z-pos+1;
		}
	}
	if (mid>0)
	{
		
		for (int i=1;i<=f;i++)
		{
			if (-a[i]>mid) continue;
			a[i]=-a[i];
			int aim=mid/a[i];
			aim=-aim;
			a[i]=-a[i];
			int pos=lower_bound(a+1,a+1+f,aim)-a;
			cnt+=f-pos+1;
			if (i>=pos) cnt--;
		}
		for (int i=1;i<=z;i++)
		{
			if (b[i]>mid) continue;
			int aim=mid/b[i];
			int pos=upper_bound(b+1,b+1+z,aim)-b;
			cnt+=pos-1;
			if (i<=pos-1) cnt--;
		}
		cnt/=2;
		cnt+=z*f+zero;
	}
	return cnt>=k;
}
signed main()
{
	scanf("%lld%lld",&n,&k);
	for (int i=1;i<=n;i++)
	{
		int num;
		scanf("%lld",&num);
		if (num<0) a[++f]=num;
		if (num>0) b[++z]=num;
		if (num==0) zero++;
	}
	zero=zero*(zero-1)/2+zero*(f+z);
	sort(a+1,a+1+f);
	sort(b+1,b+1+z);
	int l=-1e18,r=1e18;
	while (l<r)
	{
		int mid=(l+r)>>1;
		if (check(mid)) r=mid;
		else l=mid+1;
	}
	printf("%lld\n",r);
}


Measured memory_bytes: 5180
//check violation of constraints

import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.NoSuchElementException;

public class Main {

	void run() {
		FastScanner sc = new FastScanner();
		int r = sc.nextInt();
		System.out.println(r * r);
	}

	public static void main(String[] args) throws FileNotFoundException {
		new Main().run();
	}

	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}

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

	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());
	}
}

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

int main()
{

	while (1){
		int  h, m;
		string input, s1, s2, s3;

		cin >> input;
		if (input == "-") break;
		cin >> m;

		int i = 0;
		for (i = 0; i < m; i++){
			cin >> h;
			s1 = input.substr(0, h);
			s2 = input.substr(h, input.size() - h);
			s3 = s2 + s1;
			input = s3;
			
		}
		cout << s3 << endl;

	}

	return(0);
}


Measured memory_bytes: 3200
#include <stdio.h>

int main(void){
    int M1,H1,M2,H2;
    int K;
    int sum1,sum2;
    int awake;
    int answer;
    scanf("%d",&M1);   scanf("%d",&H1);
    scanf("%d",&M2);   scanf("%d",&H2);
    scanf("%d",&K);
    sum1 = M1*60 + H1;
    sum2 = M2*60 + H2;
    //起きてる時間の計算
    // sum1 23;00で sum2 5;00のとき
    // 24h-sum1 + sum2
    // sum1 10;00で　sum2 15;00
    // sum2-sum1
    if(sum1 > sum2){
        sum2 = 24*60 + sum2;
    }
    //起きている時間
    awake = sum2 - sum1;
    answer = awake - K;
    printf("%d",answer);
    return 0;
}

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

// 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() {
  std::string A;
  std::cin >> A;

  std::unordered_map<char, i64> occurrences;
  for (const char& A_i : A) {
    ++occurrences[A_i];
  }

  std::cout << 1 + A.size() * (A.size() - 1) / 2 - std::accumulate(occurrences.begin(), occurrences.end(), static_cast<i64>(0), [](const i64& sum, const std::pair<char, i64>& pair) {
    return sum + pair.second * (pair.second - 1) / 2;
  }) << std::endl;
  return 0;
}

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

using namespace std;
typedef long long ll;

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

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

int main(void){

	int N;
	cin >> N;

	ll T[N];

	for(int i=0;i<N;i++){
		cin >> T[i];
	}
	ll ans = T[0];
	for(int i=0;i<N;i++){
		ans = lcm(ans, T[i]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"io"
	"math"
	"os"
)

func Solve(stdin io.Reader, stdout io.Writer) {
	var n, d int
	_, _ = fmt.Fscanf(stdin, "%d %d\n", &n, &d)
	p := make([][]int, n)

	for i := 0; i < n; i++ {
		p[i] = make([]int, d)
		var tmp int
		for j := 0; j < d; j++ {
			_, _ = fmt.Fscan(stdin, &tmp)
			p[i][j] = tmp
		}
	}

	count := 0

	for i := 0; i < n-1; i++ {
		src := p[i]
		for j := i + 1; j < n; j++ {
			dst := p[j]
			distSq := distanceSquare(src, dst)
			dist := int(math.Sqrt(float64(distSq)))
			// distが小数だったらintへのキャストで切り捨てられてdist^2 != distSqになるはず！多分！
			if dist*dist == distSq {
				count++
			}
		}
	}
	_, _ = fmt.Fprintf(stdout, "%d\n", count)
}

func distanceSquare(src, dst []int) int {
	dimension := len(src)
	ans := 0
	for i := 0; i < dimension; i++ {
		ans += (src[i] - dst[i]) * (src[i] - dst[i])
	}

	return ans
}

func main() {
	Solve(os.Stdin, os.Stdout)
	return
}


Measured memory_bytes: 512
import collections as cl

# 全街のつながりは保証されていて、橋は3本固定なので、枝分かれしてなければたどり着けるはず
def main() :
    bridges = []
    for i in range(3) :
        in_list = [int(i) for i in input().split()]
        bridges.extend(in_list)
    
    c = cl.Counter(bridges)
    com = c.most_common()
    if (com[0][1] == 2 and com[1][1] == 2 and com[2][1] == 1 and com[3][1] == 1) :
        print("YES")
    else :
        print("NO")
        
        
    






main()

Measured memory_bytes: 3316