akhauriyash/Code-Regression huggingface dataset:
/* ex7_3
   kohei_suzuki */

#include <stdio.h>
#include <stdlib.h>

int main(void){
    int row, col; //行数,列数
    int *ture_row, *ture_col; //#の有無を保存するための配列
    char **square; //入力用配列

    scanf("%d %d",&row,&col);//入力受取

    //メモリを動的確保して多次元配列を定義する
    square = (char**)calloc(row, sizeof(char*));
    if(square == NULL){
        printf("memory allocation error.\n");
        exit(1);
    }
    for(int i=0; i<row; i++){
        square[i] = (char*)calloc(col, sizeof(char));
        if(square[i] == NULL){
            printf("memory allocation error.\n");
            exit(1);
        }
    }

    //メモリを動的確保して配列を定義する
    ture_row = (int*)calloc(row, sizeof(int));
    if(ture_row == NULL){
        printf("memory allocation error.\n");
        exit(1);
    }
    
    //メモリを動的確保して配列を定義する
    ture_col = (int*)calloc(col, sizeof(int));
    if(ture_col == NULL){
        printf("memory allocation error.\n");
        exit(1);
    }

    //squareの入力受取
    for(int i=0; i<row ;i++){ 
        for(int j=0; j<col ;j++){
            scanf(" %c",&square[i][j]);
        }
    }
 
    //記録用配列の初期化
    for(int i=0; i<row; i++){ 
        ture_row[i]=0;
    }
    for(int j=0; j<col; j++){
        ture_col[j]=0;
    }

    //#があった行i,列jを記録(true_row[i]=1,true_col[j]=1とする)
    for(int i=0; i<row; i++){
        for(int j=0; j<col; j++){
            if(square[i][j]=='#'){
                ture_row[i]=1;
                ture_col[j]=1;
            }
        }
    }

    //true_row[i]=1かつtrue_col[j]=1ならばsquare[i][j]を出力
    for(int i=0; i<row; i++){
        if(ture_row[i] == 1){
            for(int j=0; j<col; j++){
                if(ture_col[j] == 1){
                    printf("%c",square[i][j]);
                }
            }
            printf("\n"); //行終わりで改行
        }
    }
	//メモリ領域の解放
    free(ture_row);
    free(ture_col);
    for(int i=0; i<row; i++){
        free(square[i]);
    }
    free(square);
    return 0;
}


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

using namespace std;

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)

signed main(){

	vector<lli> a(3);
	REP(i,0,3)cin>>a[i];
	sort(a.begin(),a.end());

	cout<<(a[0]+a[1]==a[2]?"Yes":"No")<<endl;

	return 0;
}

Measured memory_bytes: 256
from collections import deque
N = int(input())
g = [set() for i in range(N + 1)]
for i in range(N - 1):
    a, b = map(int, input().split())
    g[a].add(b)
    g[b].add(a)
    
c = list(map(int, input().split()))
c.sort(reverse=True)

print(sum(c) - c[0])

q = deque()
nums = [0] * (N + 1)

q.appendleft(1)

while q:
  d = q.popleft()
  nums[d] = c.pop(0)
  for node in g[d]:
    if nums[node] == 0:
      q.append(node)
print(*nums[1:])


Measured memory_bytes: 7576
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
//#include <stdio.h>
//#include <stack>
//#include <queue>
#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
//#include <fstream>
//#include <list>
//#include <iomanip>
#include <stdlib.h>
#include <cctype>

using namespace std;

#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define ssort(z) sort(z.begin(),z.end())
#define rsort(z) sort(z.rbegin(),z.rend())
#define eerase(z) z.erase(unique(z.begin(),z.end()),z.end())
#define ccnt(z,w) count(z.begin(),z.end(),w)


void printVec(std::vector<int> & vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec1(std::vector<string>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec2(std::vector<Int>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}

Int gcd(Int a, Int b) {
	return b != 0 ? gcd(b, a % b) : a;
}
Int lcm(Int a, Int b) {
	return a / gcd(a, b) *b;
	//a*bは64bit integer overflow
}

bool comp(const string a, const string b) {
	return a.length() < b.length();
}

bool integer(double num) {
	return floor(num) == num;
}

string gen(int num) {
	string str = "";
	for (int i = 0; i < num; i++) str += ".";
	return str;
}
Int fact(int num) {
	if (num == 0) return 1;
	else return num * fact(num - 1);
}


int main() {
	int a, b; cin >> a >> b;
	if (a <= 8 && b <= 8)cout << "Yay!";
	else cout << ":(";

	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef       long long int      ll;
#define       READ               freopen("in.txt", "r", stdin);
#define       WRITE              freopen("out.txt", "w", stdout);
#define       optimize           ios::sync_with_stdio(0);cin.tie(0);
#define       RESET(a, b)        memset(a, b, sizeof(a))
#define       gcd(a, b)          __gcd(a, b)
#define       MX                 300005
#define       MOD               1000000007
inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p & 1LL) r = modMul(r, b); b = modMul(b, b); p >>= 1LL; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }
bool cmp(ll x,ll y)
{
   return x>y;
}
int main(void)
{
   long long int t,n,m,k,x,y,a[200001];
   vector<ll> v,v1,v2;
   vector< pair <ll,ll> >p,p1,p2;
   set<ll> st;
   priority_queue<ll> pq;
   priority_queue< ll,vector<ll>,greater<ll> > lpq;
   priority_queue< pair<ll,ll> > phpq;
   priority_queue< pair<ll,ll>,vector< pair<ll,ll> >,greater< pair <ll,ll> > > plpq;
   string s;
   //cin>>t;
   //while(t--)
   //{
      cin>>n;
      //ll cnt[105]={};
      for(ll i=0;i<n;i++)
      {
         cin>>x;
         //cnt[x]++;
         //if(st.find(x)==st.end())
         v.push_back(x);
         //st.insert(x);
      }
      sort(v.begin(),v.end());
      ll ans=0,sum;
      for(ll i=0;i<n-2;i++)
      {
         for(ll j=i+1;j<n;j++)
         {
            if(v[i]==v[j])
               continue;
            sum=v[i]+v[j];
            for(ll k=j+1;k<n;k++)
            {
               if(sum>v[k])
               {
                  if(v[i]!=v[j] && v[j]!=v[k] && v[i]!=v[k])
                     ans++;
               }
            }
         }
      }
   //}
   cout<<ans<<endl;
   return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <climits>
#include <bitset>
#include <list>
#include <map>
#include <set>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

#define MAX 2000

int u[MAX][MAX], d[MAX][MAX], l[MAX][MAX], r[MAX][MAX];

int main(){
	int h, w;
	cin >> h >> w;
	string s[h];
	for(int i=0; i<h; i++) cin >> s[i];

	for(int i=0; i<h; i++){
		for(int j=0; j<w; j++){
			if(s[i][j]=='#') l[i][j]=0;
			else{
				if(j==0) l[i][j]=1;
				else l[i][j]=l[i][j-1]+1;
			}
		}
	}
	for(int i=0; i<h; i++){
		for(int j=w-1; j>=0; j--){
			if(s[i][j]=='#') r[i][j]=0;
			else{
				if(j==w-1) r[i][j]=1;
				else r[i][j]=r[i][j+1]+1;
			}
		}
	}
	for(int j=0; j<w; j++){
		for(int i=0; i<h; i++){
			if(s[i][j]=='#') u[i][j]=0;
			else{
				if(i==0) u[i][j]=1;
				else u[i][j]=u[i-1][j]+1;
			}
		}
	}
	for(int j=0; j<w; j++){
		for(int i=h-1; i>=0; i--){
			if(s[i][j]=='#') d[i][j]=0;
			else{
				if(i==h-1) d[i][j]=1;
				else d[i][j]=d[i+1][j]+1;
			}
		}
	}

	int ans=0;
	for(int i=0; i<h; i++){
		for(int j=0; j<w; j++){
			ans=max(ans, l[i][j]+r[i][j]+u[i][j]+d[i][j]-3);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 66816
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#define rep(i, a, b) for(int i = a; i < (b); ++i)
using namespace std;
typedef long long ll;

vector<pair<int, int>> to[100010];
bool visited[100010];
ll dist[100010];
int main() {
    
    int n;
    cin >> n;
    int sum = 0;
    vector<int> s(n);
    vector<int> t(n+1);
    rep(i,0,n){
        cin >> s[i];
        sum+=s[i];
        t[i+1] = t[i]+s[i];
    }
    
    int ans = 0;
    rep(i,0,n){
        if((sum-s[i])%10)ans = max(sum-s[i], ans);
    }
    rep(i,0,n){
        if(sum%10)ans = max(sum, ans);
        sum-=s[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 5980
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<cstdio>
#include<set>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repn(i, n) for(int i = 1; i <= n; i++) 

int main(){
    int N; cin >> N;
    int index[N+1];
    repn(i, N){
        int p; cin >> p;
        index[p] = i;
    }
    multiset<int> S{0, 0, N+1, N+1};
    S.insert(index[N]);
    long sum = 0;
    for (int a = N-1; a >= 1; a--){
        auto itr = S.lower_bound(index[a]);
        int R1 = *itr; int R2 = *++itr; --itr;
        int L1 = *--itr; int L2 = *--itr;
        long c = (L1-L2)*(R1-index[a]) + (index[a]-L1)*(R2-R1);
        sum += c * a;
        S.insert(index[a]);
    }
    cout << sum << endl;
}

Measured memory_bytes: 5376
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int n, k;
vector<int> x, y, c;
double distance(double px, double py) {
  vector<double> dis(n);
  for (int i = 0; i < n; ++i) {
    dis[i] = c[i] * hypot(px - x[i], py - y[i]);
  }
  nth_element(dis.begin(), dis.begin() + k - 1, dis.end());
  return dis[k - 1];
}
double distance_lb(double px, double py, double r) {
  vector<double> dis(n);
  for (int i = 0; i < n; ++i) {
    dis[i] = c[i] * hypot(max(abs(px - x[i]) - r, 0.0), max(abs(py - y[i]) - r, 0.0));
  }
  nth_element(dis.begin(), dis.begin() + k - 1, dis.end());
  return dis[k - 1];
}
int main() {
  cin >> n >> k;
  x.resize(n);
  y.resize(n);
  c.resize(n);
  for (int i = 0; i < n; ++i) {
    cin >> x[i] >> y[i] >> c[i];
  }
  queue<tuple<double, double, double>> que;
  double res = 1e9;
  que.emplace(0, 0, 1000);
  while (!que.empty()) {
    double px,py,r;
    tie(px, py, r) = que.front();
    que.pop();
    double lb = distance_lb(px, py, r);
    if (res-lb>5e-7*max(1.0, lb)) {
      res = min(res, distance(px, py));
      for (double dx:{-0.5, 0.5}) {
        for (double dy:{-0.5,0.5}) {
          que.emplace(px + dx * r, py + dy * r, r / 2);
        }
      }
    }
  }
  cout << fixed << setprecision(15) << res << endl;
  return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
int main(void){
int n,m,l,i,j,k;
int A[100][100],B[100][100];
long C[100][100];
for(i=0;i < 100;i++){
for(j=0;j < 100;j++){
A[i][j]=0;
B[i][j]=0;
C[i][j]=0;
}
}
scanf("%d %d %d",&n ,&m ,&l);
for(i=0;i < n;i++){
for(j=0;j < m;j++){
if (j == m-1){
scanf("%d\n",&A[i][j]);
}else{
scanf("%d ",&A[i][j]);
}
}
}
for(i=0;i < m;i++){
for(j=0;j < l;j++){
if (j == l){
scanf("%d\n",&B[i][j]);
}else{
scanf("%d ",&B[i][j]);
}
}
}
for(i=0;i < n;i++){
for(j=0;j < l;j++){
for(k=0;k < m;k++){
C[i][j] += A[i][k]*B[k][j];
}
if (j == l-1){
printf("%ld\n",C[i][j]);
}else{
printf("%ld ",C[i][j]);
}
}
}
return 0;
}

Measured memory_bytes: 760
# coding: utf-8
# Your code here!

n,y=map(int,input().split())
for i in range(n+1):
    for j in range(n+1-i):
        if(i*10000+j*5000+(n-i-j)*1000==y):
            print(i,j,n-i-j)
            exit()
print(-1,-1,-1)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define F first
#define S second

using namespace std;
typedef pair<int,int> P;
typedef vector<int> ivec;

const int MOD=1000000007;
int INF=100100100100100;

signed main(){
  int a[5];
  rep(i,5)cin>>a[i];
  int k;cin>>k;
  if(a[4]-a[0]<=k)cout<<"Yay!"<<endl;
  else cout<<":("<<endl;
  return 0;
}


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

using namespace std;

int main() {
  int a, b, c, d;
  scanf("%d %d %d %d", &a, &b, &c, &d);
  printf(abs(a - c) <= d || abs(a - b) <= d && abs(b - c) <= d ? "Yes\n" : "No\n");
  return 0;
}

Measured memory_bytes: 256
N=int(input())
D=list()
for i in range(N):
    tmp=list(map(int,input().split()))
    D.append(tmp[0]==tmp[1])
for i in range(N-2):
    if D[i]==D[i+1]==D[i+2]==True:
        print("Yes")
        break
else:
    print("No")

Measured memory_bytes: 9176
n=int(input())
l=sorted([v-i-1 for i,v in enumerate(list(map(int,input().split())))])
if n%2:
    m=l[n//2]
else:
    m=(l[n//2]+l[n//2-1])/2
print(int(sum(abs(m-v) for v in l)))

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

int lat[5][5];

vector<vector<int>> bx = {
    {0, 1, 2, 3, 4},
    {0, 1, 2, 3, 4},
    {0, 1, 2, 3, 4},
    {0, 1, 2, 3, 4},
    {0, 1, 2, 3, 4},
    {0, 0, 0, 0, 0},
    {1, 1, 1, 1, 1},
    {2, 2, 2, 2, 2},
    {3, 3, 3, 3, 3},
    {4, 4, 4, 4, 4}
};

vector<vector<int>> by = {
    {0, 0, 0, 0, 0},
    {1, 1, 1, 1, 1},
    {2, 2, 2, 2, 2},
    {3, 3, 3, 3, 3},
    {4, 4, 4, 4, 4},
    {0, 1, 2, 3, 4},
    {0, 1, 2, 3, 4},
    {0, 1, 2, 3, 4},
    {0, 1, 2, 3, 4},
    {0, 1, 2, 3, 4}
};

string rev(string s) {
    reverse(s.begin(), s.end());
    return s;
}

int dfs(vector<string> &v, int k) {
    if (k == 10) {
        return 1;
    }
    vector<string> S(1, v[k]);
    if (v[k] != rev(v[k])) {
        S.push_back(rev(v[k]));
    }
    int ret = 0;
    for (string bloc : S) {
        for (int i=0; i<10; ++i) {
            bool ok = true;
            vector<int> t;
            for (int j=0; j<5; ++j) {
                if ((lat[by[i][j]][bx[i][j]] & 1 && bloc[j] - '0' == 0) ||
                    (lat[by[i][j]][bx[i][j]] & 2 && bloc[j] - '0' == 1)) {
                    ok = false;
                    break;
                }
                t.push_back(lat[by[i][j]][bx[i][j]]);
            }
            if (ok) {
                for (int j=0; j<5; ++j) {
                    lat[by[i][j]][bx[i][j]] |= (bloc[j] - '0' + 1);
                }
                ret += dfs(v, k+1);
                for (int j=0; j<5; ++j) {
                    lat[by[i][j]][bx[i][j]] = t[j];
                }
            }
        }
    }
    return ret;
}

int main() {
    vector<string> v(10);
    while (cin >> v[0], v[0] != "END") {
        for (int i=1; i<10; ++i) {
            cin >> v[i];
        }
        memset(lat, 0, sizeof lat);
        int ret = dfs(v, 0);
        cout << (ret == 0 ? 0 : ret / 8) << endl;
    }
    return 0;
}

Measured memory_bytes: 1220
#include<iostream>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
using ll = long long;
using P = pair<int, int>;
#include<algorithm>
#include<math.h>
#include<map>
#include<queue>

int main() {
	int n;
	cin >> n;
	bool ok = false;
	rep(i, 9) {
		rep(j, 9) {
			int c = (i + 1) * (j + 1);
			if (c == n) {
				ok = true;
			}
		}
			
	}
	if (ok) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}
	return 0;
}

Measured memory_bytes: 256
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::{Bytes, Chars};
#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
	input! {
		d: usize,
		t: usize,
		s: usize,
	}

	if d <= s*t {
		println!("Yes");
	}
	else {
		println!("No");
	}
}



Measured memory_bytes: 2172
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main() {
  string S;
  cin >> S;
  bool eas = true;
  
  for(int i = 1; i < S.size(); i++){
    if (S.at(i-1) == S.at(i)) eas = false;
  }
  if (eas) cout << "Good" << endl;
  else cout << "Bad" << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int m,n;//y,t
int f[100][100],ans;
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};
int ex(int x,int y,int sum)
{
    f[x][y] = 0;
    //printf("[%d]\n",sum);
    for(int i = 0; i < 4; i++)
    {
        if(0 > x + dx[i]||x + dx[i] >= m||0 > y + dy[i]||y + dy[i] >= n);
        else if(f[x + dx[i]][y + dy[i]] == 1)ex(x + dx[i],y + dy[i],sum + 1);
    }
    if(ans < sum)ans = sum;
    /*for(int i = 0; i < 5; i++)
    {
        if(i == 4&&ans < sum)ans = sum;
        if(i == 4)break;
        if(0 > x + dx[i]||x + dx[i] >= m||0 > y + dy[i]||y + dy[i] >= n);
        else if(f[x + dx[i]][y + dy[i]] == 0);
        else break;
    }*/
    f[x][y] = 1;
    return 0;
}
int main()
{

    while(1)
    {
        scanf("%d%d",&m,&n);
        if(n == 0&&m == 0)break;
        ans = 0;
        for(int i = 0; i < n; i++)
        {
            for(int j = 0; j < m; j++)
            {
                f[i][j] = 0;
            }
        }
        for(int i = 0; i < n; i++)
        {
            for(int j = 0; j < m; j++)
            {
                scanf("%d",&f[i][j]);
            }
        }

        for(int i = 0; i < n; i++)
        {
            for(int j = 0; j < m; j++)
            {
                if(f[i][j] == 1)ex(i,j,1);
            }
        }
        printf("%d\n",ans);
    }
}

Measured memory_bytes: 1056
import sys
import itertools

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, K = lr()
XY = [lr() for _ in range(N)]
XY.sort()
answer = float('inf')
# 端の4点、まずはx軸の2点を選ぶ
for left,right in itertools.combinations(range(N),2):
  width = XY[right][0] - XY[left][0]
  pts = sorted(XY[left:right+1], key = lambda xy: xy[1])
  if len(pts) < K:
    continue
  for D in range(len(pts) - K + 1):
    if D + K - 1 >= len(pts):
      break
    y_max = pts[D+K-1][1]
    y_min = pts[D][1]
    area = (y_max - y_min) * width
    if area < answer:
      answer = area
    
print(answer)

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

#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define lfs <<fixed<<setprecision(10)<<
#define test cout<<"test"<<endl;
#define fi first
#define se second
#define MP make_pair
#define rep(i,n,m) for(ll i = n; i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = n - 1; i >= (ll)(m); i--)
typedef long long ll;
typedef long double ld;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T>
void chmin(T &a,T b){if(a>b)a=b;}
template<typename T>
void chmax(T &a,T b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void pmod(ll &a,ll b,ll c){a=(b+c)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void qmod(ll &a,ll b,ll c){a=(b*c)%MOD;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>v,ll n){cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
template<typename T>
void emp(map<T,ll>&m, T x){m.emplace(x,0).first->second++;}

int main(){
  cin.tie(NULL);
  ios_base::sync_with_stdio(false);
  ll res=0,res1=INF,res2=-INF,buf=0;
  bool judge = true;
  ll n;cin>>n;
  vector<ll>h(n);
  rep(i,0,n)cin>>h[i];
  reverse(ALL(h));
  ll cnt=0;
  rep(i,0,n-1){
    if(h[i]<=h[i+1])cnt++;
    else{
      chmax(res,cnt);
      cnt=0;
    }
  }
  chmax(res,cnt);
  cout<<res<<endl;
  return 0;
}

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

int n;

// char X[100][100];
// int dp[1000000001];


int main(void){
    cin >> n;
    int a[n][n];
    int d[n][n];
    REP(i,0,n) REP(j,0,n) cin >> a[i][j], d[i][j] = a[i][j];
    
    REP(k,0,n) REP(i,0,n) REP(j,0,n) {
        if (k == i || i == j || j == k || d[i][k] == MAX || d[k][j] == MAX) continue;
        if (d[i][k] + d[k][j] == a[i][j]) d[i][j] = MAX;
        else if (d[i][k] + d[k][j] < a[i][j]) {
            cout << -1 << endl;
            return 0;
        }
    }

    long long ans = 0;
    REP(i,0,n) REP(j,0,n) {
        if(d[i][j] != MAX) {
            ans += d[i][j];
        }
    }

    cout << ans/2 << endl;
}

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

int main()
{    
    array<string, 7> days = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
    string s;
    cin >> s;
    auto itr = find(days.begin(), days.end(), s);
    int d_idx = distance(days.begin(), itr);
    int d_remain = 7 - d_idx;

    cout << d_remain << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
ll gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }     //最小公倍数
using Graph = vector<vector<int>>;
ll inf=300000000000000000;
const double PI = 3.14159265358979323846;
int main(){
  int n;
  cin >> n;
  int ans[n];
  rep(i,n)ans[i]=0;
  rep(i,100){
    rep(j,100){
      rep(p,100){
        int a=i+1,b=j+1,c=p+1;
        int u=a*a+b*b+c*c+a*c+a*b+b*c;
        u--;
        if(u<n&&u>=0)ans[u]++;
      }
    }
  }
  rep(i,n){
    cout << ans[i] << endl;
  }
}


Measured memory_bytes: 3592
N = int(input())
A = list(map(int,input().split()))
def waru(A, count):
    B = []
    for a in A:
        if a%2 != 0:
            return count
        else:
            B.append(int(a/2))
    return waru(B, count+1)
print(waru(A, 0))

Measured memory_bytes: 3188
n,x=map(int,input().split())
a=list(map(int,input().split()))
b=[]
for i in range(n):
	b.append(abs(a[i]-x))
import fractions
gcd=b[0]
for i in range(n-1):
	gcd=fractions.gcd(b[i+1],gcd)
print(gcd)



Measured memory_bytes: 15020
#include <iostream>

using namespace std;


const int N = 500500;
long long k;
int n,A[N],B[N],pos[N],vis[N],len;
int main(){
    cin >> n >> k;
    for (int i = 1; i <= n; i++)
        cin >> A[i];
    B[0] = 1;
    /*
    for (int i = 1; i <= 2 * n; i++){
        B[i] = A[B[i - 1]];
    }
    int start = 1,len = 0;
    for (int i = 1; i <= n; i++){
        bool flag = false;
        for (int j = 1; j <= n - i; j++){
            bool check = true;
            for (int l = i,r = j + i; l <= i + j - 1 && r <= i + 2 * j - 1; l++,r++){
                if (B[l] != B[r]) check = false;
            }
            if (check){
                flag = true;
                len = j;
                break;
            }
        }
        if (flag){ 
            start = i;
            break;
        }
    }
    */
    for (int i = 1; i <= n; i++){
        B[i] = A[B[i - 1]];
    }
    int len = 0,start = 0;
    for (int i = 1; i <= n; i++){
        pos[B[i]]++;
        if (pos[B[i]] > 1){
            len = i - vis[B[i]];
            start = vis[B[i]];
            break;
        }
        vis[B[i]] = i;
    }
    long long w = k - start + 1;
    // << vis[3];
    if (k < start) cout << B[k];
    else if (w % len == 0) cout << B[len + start - 1];
    //for (int i = 1; i <= n; i++) cout << B[i];
    else cout << B[w % len + start - 1];
    return 0;
}

Measured memory_bytes: 6780
#include<cstdio>
const int N=998244353;
int n,s,temp,x,f[2][3005],a[3005];
int main()
{
	scanf("%d%d",&n,&s);
	for(int i=1;i<=n;++i)scanf("%d",&a[i]);
	f[0][0]=2;f[0][a[1]]=1;
	for(int i=2;i<=n;++i)
	  {
	  	x^=1;
	  	for(int j=0;j<a[i];++j)
	  	  {
	  	  	f[x][j]=f[x^1][j]<<1;
	  	  	if(f[x][j]>N)f[x][j]-=N;
		  }
		for(int j=a[i];j<=s;++j)
	  	  {
	  	  	f[x][j]=f[x^1][j]<<1;
	  	  	if(f[x][j]>N)f[x][j]-=N;
	  	  	f[x][j]+=f[x^1][j-a[i]];
	  	  	if(f[x][j]>N)f[x][j]-=N;
		  }
	  }
	printf("%d",f[x][s]);
}

Measured memory_bytes: 1760
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
#include <numeric>
#include <random>
#include <queue>

using namespace std;

const int MOD = 1000000007;
typedef long long ll;

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N,K;
  cin>>N>>K;
  vector<int> h(N),dp(N,MOD);
  for(int i=0;i<N;i++)cin>>h[i];

  dp[0]=0;
  for(int i=0;i<N-1;i++){
    for(int k=0;k<K;k++){
      if(i-k<0)break;
      dp[i+1]=min(dp[i-k]+abs(h[i+1]-h[i-k]),dp[i+1]);
    }
  }

  cout<<dp[N-1]<<endl;
}


Measured memory_bytes: 1024
#include <stdio.h>

int main( void ) {
	int n, a, b, c;

	for ( scanf( "%d", &n ); n--; scanf( "%d %d %d", &a, &b, &c ), puts( a * a + b * b == c * c || b * b + c * c == a * a || c * c + a * a == b * b ? "YES" : "NO" ) ) ;

	return 0;
}

Measured memory_bytes: 580
#include <stdio.h>

int main(void)
{
	int n, i;
	long int min ,max;
	long int sum = 0;
	int a;
	scanf("%d", &n);
  	for(i=0;i<n;i++){
   		scanf("%d", &a);
     	sum = sum + a;
		if(i == 0){
			min = a;
			max = a;
		}
		if(min > a){
			min = a;
        }
 		
		if(max< a){
			max = a;
		}
	}
	
	printf("%ld %ld %ld\n", min, max, sum);
    return 0;
}
	
    	
  

Measured memory_bytes: 600
from scipy.sparse.csgraph import floyd_warshall

N,M,L=map(int,input().split())

A=[[10**12 for i in range(N+1)]for j in range(N+1)]
B=[[10**12 for i in range(N+1)]for j in range(N+1)]
for i in range(M):
    a,b,c=map(int,input().split())
    if c<=L:
        A[a][b]=c
        A[b][a]=c
        B[a][b]=1
        B[b][a]=1

#print(A)


A= floyd_warshall(A,directed = False)
#print(A)
for i in range(N+1):
    for j in range(N+1):
        if A[i][j]<=L:
            B[i][j]=1
"""for c in range(1,N+1):
    for a in range(1,N+1):
        for b in range(1,N+1):
            A[a][b]=min(A[a][b],A[a][c]+A[c][b])
            if A[a][b]<=L:
                B[a][b]=1"""
#print(B)

B= floyd_warshall(B,directed = False)
"""for c in range(1,N+1):
    for a in range(1,N+1):
        for b in range(1,N+1):
            B[a][b]=min(B[a][b],B[a][c]+B[c][b])"""

#print(B)
Q=int(input())
for i in range(Q):
    s,t=map(int,input().split())
    if B[s][t]==10**12:
        print(-1)
    else:
        print(int(B[s][t]-1))


Measured memory_bytes: 19644
import sys
import math
X = int(input())
if X == 2:
    print(2)
    sys.exit()
if X % 2 == 0:
    X += 1

while True:
    s = int(math.sqrt(X))
    flg = True
    for i in range(3, s, 2):
        if X % i == 0:
            flg = False
            break
    if flg:
        print(X)
        sys.exit()
    else:
        X += 2


Measured memory_bytes: 9064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
#define FASTIO() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

const int N = 100005, M = 1000000007, BIG = 0x3f3f3f3f;

int n;
string s;

void Process() {
  n = s.length();
  if (s[2] == s[3] && s[4] == s[5])
    cout << "Yes\n";
  else
    cout << "No\n";
}

int main() {
  FASTIO();

  while (cin >> s) {
    Process();

    if (cin.eof())
      break;
  }

  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

typedef struct _node {
    int val;
    struct _node *left;
    struct _node *right;
    struct _node *parent;
} NODE;

NODE *root = NULL;

void insert(int val) {
    NODE *x = new NODE;
    x->val = val;
    x->left = NULL;
    x->right = NULL;
    x->parent = NULL;
    NODE *y = NULL; // parent
    NODE *z = root; // interator
    while (z != NULL) {
        y = z;
        if (x->val <= z->val) {
            z = z->left;
        } else {
            z = z->right;
        }
    }
    x->parent = y;
    if (y == NULL) {
        root = x;
    } else if (x->val <= y->val) {
        y->left = x;
    } else {
        y->right = x;
    }
}

NODE *find(int val) {
    NODE *p = root;
    while (p != NULL && p->val != val) {
        if (val <= p->val) {
            p = p->left;
        } else {
            p = p->right;
        }
    }
    return p;
}

NODE *deleteNode(NODE *x) {
    if (x->left == NULL && x->right == NULL) {
        // case 1
        NODE *y = x->parent;
        if (y == NULL) {
            root = NULL;
        } else if (x->val <= y->val) {
            y->left = NULL;
        } else {
            y->right = NULL;
        }
    } else if (x->left != NULL && x->right != NULL) {
        // case 3
        NODE *p = x->right;
        while (p->left) {
            p = p->left;
        }
        deleteNode(p);
        x->val = p->val;
    } else {
        // case 2
        NODE *y = x->parent;
        NODE *z = x->left ? x->left : x->right;
        if (y == NULL) {
            root = z;
        } else if (x->val <= y->val) {
            y->left = z;
        } else {
            y->right = z;
        }
        z->parent = y;
    }
    return x;
}

void preorder(NODE *p) {
    if (p == NULL) {
        return;
    }
    printf(" %d", p->val);
    preorder(p->left);
    preorder(p->right);
}

void inorder(NODE *p) {
    if (p == NULL) {
        return;
    }
    inorder(p->left);
    printf(" %d", p->val);
    inorder(p->right);
}

int main() {
    int n, val;
    scanf("%d", &n);
    char cmd[100];
    for (int i = 0; i < n; i++) {
        scanf("%s %d", cmd, &val);
        if (cmd[0] == 'i') {
            insert(val);
        } else if (cmd[0] == 'f') {
            if (find(val) == NULL) {
                printf("no\n");
            } else {
                printf("yes\n");
            }
        } else if (cmd[0] == 'd') {
            NODE *x = find(val);
            deleteNode(x);
        } else {
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        }
    }
    return 0;
}



Measured memory_bytes: 21340
//
// Created by yamunaku on 2019/07/30.
//

#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repl(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perl(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD9 998244353
#define MOD1 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)
#define CST(x) cout<<fixed<<setprecision(x)

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int>> mti;
typedef vector<ll> vl;
typedef vector<vector<ll>> mtl;

int main(){
    int k,x,y;
    cin >> k >> x >> y;
    int vx=(x==0?1:x/abs(x));
    int vy=(y==0?1:y/abs(y));
    x=abs(x),y=abs(y);
    if(k%2==0){
        if((x+y)%2==1){
            cout << -1 << endl;
            return 0;
        }
    }
    int nx=0,ny=0;
    if((x+y)%k==0){
        int a = (x+y)/k;
        cout << a << endl;
        rep(i,a){
            int t=k;
            int d=min(x-nx,t);
            nx+=d;
            t-=d;
            ny+=t;
            cout << vx*nx SP vy*ny << endl;
        }
        return 0;
    }
    int a = (x+y+k-1)/k;
    while(1){
        if((a*k-x-y)%2) a++;
        int b=(a*k-x-y)/2;
        int ta=a;
        nx=0,ny=0;
        while(b>0){
            ta--;
            int m=min(b,k);
            b-=m;
            if(k-m<=x){
                nx+=k-m;
                ny+=-m;
            }else{
                nx+=-m;
                ny+=k-m;
            }
        }
        rep(i,ta){
            int t=k;
            int d=min(x-nx,t);
            nx+=d;
            t-=d;
            ny+=t;
        }
        if(nx==x&&ny==y) break;
        a++;
    }
    int b=(a*k-x-y)/2;
    nx=0,ny=0;
    cout << a << endl;
    while(b>0){
        a--;
        int m=min(b,k);
        b-=m;
        if(k-m<=x){
            nx+=k-m;
            ny+=-m;
        }else{
            nx+=-m;
            ny+=k-m;
        }
        cout << vx*nx SP vy*ny << endl;
    }
    rep(i,a){
        int t=k;
        int d=min(x-nx,t);
        nx+=d;
        t-=d;
        ny+=t;
        cout << vx*nx SP vy*ny << endl;
    }
    return 0;
}


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

void ansFlg(int x, int y){
    if(x == y){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}
int main(){
    int N,M;
    cin >> N >> M;
    ansFlg(N, M);
}

Measured memory_bytes: 256
import Data.List
main = do
  n <- read <$> getLine
  xy <- sequence $ replicate n $ do
        a <- read <$> getLine
        sequence $ replicate a $ do
          [x,y] <- map read . words <$> getLine
          return (x,y)
  print $ maximum $ length <$> filter (ok xy) (subsequences [1..n])
ok xys kinds = and [(y == 0) /= (x `elem` kinds) | i <- kinds,(x,y) <- xys !! (i-1)]

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

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

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

    // dp[i][j][k] = up to i-th card, used j cards, sum k
    vector<vector<vector<long long int>>> dp(51,vector<vector<long long int>>(51, vector<long long int>(2501)));
    dp[0][0][0] = 1;
    for(int i=0; i<n; i++){
        for(int j=0; j<n; j++){
            for(int k=0; k<2501; k++){
                dp[i+1][j][k] += dp[i][j][k];
                if(k - x[i] >= 0) dp[i+1][j+1][k] += dp[i][j][k - x[i]];
                //if(dp[i][j][k] != 0) cout << "dp[" << i << "][" << j << "][" << k << "] = " << dp[i][j][k] << endl;
            }
        }
    }

    long long int ans = 0;
    for(int i=1; i<=n; i++){
        ans += dp[n][i][i * a];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 52224
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,string>;
using Map = map<string,ll>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;

int main(){
    ll N;
    cin >> N;   
    ll K;
    cin >> K;
    vector<ll> p(N,0);
    for(ll i=0;i<N;i++){
        cin>>p[i]
    ;}
    ll sum=0;
    for(ll i=0;i<K;i++){
        sum+=p[i]
    ;}
    ll Max=sum;
    for(ll i=0;i<N-K;i++){
        sum-=p[i];
        sum+=p[i+K];
        Max=max(sum,Max);
    ;}
    cout << fixed << setprecision(12);
    cout<<(double)Max/2+0.5*K<<endl;


return 0;
}


Measured memory_bytes: 1792
#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<ll,ll>;

bool pairCompare(const P& firstElof, const P& secondElof){
  return firstElof.first > secondElof.first;
}

int main() {
  int N,M;
  cin >> N >> M;
  vector<ll> A(N);
  rep(i,N){
    int a;
    cin >> a;
    A.at(i) = a;
  }
  
  vector<P> X(M);
  rep(i,M){
    int b,c;
    cin >> b >> c;
    X.at(i) = make_pair(c,b);
  }

  sort(A.begin(), A.end(), greater<ll>());
  sort(X.begin(), X.end(), pairCompare);
 
  ll ans = 0;
  int aind = 0;
  int xind = 0;
  rep(i,N){
    if (A[aind] >= X[xind].first) {
      ans += A[aind];
      aind++;
    } else {
      ans += X[xind].first;
      X[xind].second--;
      if (X[xind].second == 0) {
        xind++;
      }
    }
    //cout << i << " : " << ans << endl;
  }

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


Measured memory_bytes: 5608
#include "bits/stdc++.h"
using namespace std;
int ok[500][500];
int m[1000][1000];
int main(){
    int c,n;
    cin>>c>>n;
    memset(ok,0,sizeof(ok));
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            char ch;
            cin>>ch;
            m[j][i]=ch-'0';
        }
    }
    int ans=0,cnt=0;
    for(int i=0;i<n/2;i++)for(int j=0;j<n/2;j++){
        ok[i][j]=m[i][j]+m[n-i-1][j]+m[n-i-1][n-j-1]+m[i][n-j-1];
        if(ok[i][j]%4==0)cnt++;
    }
    if(cnt==(n/2)*(n/2))ans++;
    c--;
    while(c--){
        int d;
        cin>>d;
        while(d--){
            int a,b;
            cin>>a>>b;a--;b--;
            if(m[b][a]){
            
                m[b][a]=0;
                a=a>=n/2?n-a-1:a;
                b=b>=n/2?n-b-1:b;
                ok[b][a]--;
                if(ok[b][a]==3)cnt--;
                if(ok[b][a]==0)cnt++;
            }else{
                m[b][a]=1;
                a=a>=n/2?n-a-1:a;
                b=b>=n/2?n-b-1:b;
                ok[b][a]++;
                if(ok[b][a]==1)cnt--;
                if(ok[b][a]==4)cnt++;
            }
        }
        if(cnt==(n/2)*(n/2))ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 7976
#include "bits/stdc++.h"

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

const ll INF = 1LL << 60;
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

#define int long long

inline void my_io() {

	std::ios::sync_with_stdio(false);

	std::cin.tie(0);

	cout << fixed << setprecision(10);

}

signed main() {
	ll d;

	cin >> d;

	if (d == 25) {
		cout << "Christmas" << endl;
	}
	else if (d == 24) {
		cout << "Christmas Eve" << endl;
	}
	else if (d == 23) {
		cout << "Christmas Eve Eve" << endl;
	}
	else {
		cout << "Christmas Eve Eve Eve" << endl;
	}
}

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

ll inf=9223372036854775806;

int main()
{
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false); cin.tie(0);
	int n;
	cin>>n;
	if (n<=111){cout<<"111";}
	else if (n<=222){cout<<"222";}
	else if (n<=333){cout<<"333";}
	else if (n<=444){cout<<"444";}
	else if (n<=555){cout<<"555";}
	else if (n<=666){cout<<"666";}
	else if (n<=777){cout<<"777";}
	else if (n<=888){cout<<"888";}
	else {cout<<"999";}
	return 0;
}

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

int main() {
  int N;
  int ans = 0;

  cin >> N;
  for(int i=1;i<=N;++i){
    int s; cin >> s;
    if(i%2 == 1 && s%2 == 1) ans += 1;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3564
import sys, random, math
from bisect import bisect_left, bisect_right
input = sys.stdin.readline

def main():
    inf = 10 ** 20

#    t = int(input())
#    t, a, b = map(int, input().split())
    t = 1
    
    for _ in range(1, t+1):
    #    print("Case #{}: ".format(_), end = '')
        
        n = int(input())
        ans = 1
        for x in sorted([int(x) for x in input().split()]):
            ans *= int(x)
            if(ans > 1e18):
                ans = -1
        
                break
        
        print(ans)
        
main()

Measured memory_bytes: 94080
let count_divisors n =
  let rec count_div_aux n k ret = match k with
    | k when n = k -> ret + 1
    | k when n mod k = 0 -> count_div_aux n (k+1) (ret+1)
    | _ -> count_div_aux n (k+1) ret
  in
  if n mod 2 = 0 then 0 else count_div_aux n 1 0

let eights n =
  let rec eights_aux n k ret = match (n, ret) with
    | (n, ret) when k > n -> ret
    | (n, ret) when (count_divisors k) = 8 -> eights_aux n (k+1) (ret+1)
    | _ -> eights_aux n (k+1) ret
  in
  eights_aux n 105 0

let () =
  let rec read () =
    try let ans = (Scanf.scanf "%d\n" eights) in
        Printf.printf "%d\n" ans
    with End_of_file -> ()
  in
  read ()
;;


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

int main()
{
  int n, ans;
  cin >> n;
  ans = n;
  string s;
  cin >> s;

  for (int i = 0; i < n - 1; i++)
  {
    if (s[i] == s[i + 1])
      ans--;
  }
  cout << ans << endl;
}

Measured memory_bytes: 512
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;

int main(){
  int n,x,y;
  vector<int> v[20100];
  const int lim = 10000,lim2 = 20000;
  
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    scanf("%d%d",&x,&y);
    v[x+lim].push_back(y+lim);
  }

  for(int i=0;i<=lim2;i++)sort(v[i].begin(),v[i].end());
  
  int ans = 10*lim*lim;

  for(int i=0;i<=lim2;i++){
    if(v[i].empty())continue;
    for(int j=0;j<v[i].size();j++){
      for(int k=i+1;k<=lim2;k++){
	if((k-i)*(k-i)>=ans)break;
	if(v[k].empty())continue;
	
	int p = lower_bound(v[k].begin(),v[k].end(),v[i][j]) - v[k].begin();
	if(p)ans = min(ans,(v[k][p-1]-v[i][j])*(v[k][p-1]-v[i][j])+(k-i)*(k-i));
	if(p!=v[k].size())ans = min(ans,(v[k][p]-v[i][j])*(v[k][p]-v[i][j])+(k-i)*(k-i));
      }
    }
  }
 
  printf("%d\n",ans);
}

Measured memory_bytes: 5276
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h,w;
    cin >> h >> w;
    int now = 0;
    vector<string> s(h);
    REP(i,h) cin >> s[i];
    REP(i,h){
        int next = -1;
        REP(j,w){
            if(j<now){
                if(s[i][j]=='#'){
                    puts("Impossible");
                    return 0;
                }
            }else{
                if(next==-1||next==j-1){
                    if(s[i][j]=='#'){
                        next = j;
                    }
                }else{
                    if(s[i][j]=='#'){
                        puts("Impossible");
                        return 0;
                    }
                }
            }
        }
        now = next;
    }
    puts("Possible");
    return 0;
    return 0;
}

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

#define F first
#define S second
#define pb push_back

const long long MOD = 1e9 + 7;
const long long MAXN = 1e6 + 1;
using namespace std;

typedef long long ll;

long long readInt() {
    bool minus1 = false;
    long long result = 0;
    char ch;
    ch = getchar();
    while (true) {
        if (ch == '-') break;
        if (ch >= '0' && ch <= '9') break;
        ch = getchar();
    }
    if (ch == '-') minus1 = true; else result = ch-'0';
    while (true) {
        ch = getchar();
        if (ch < '0' || ch > '9') break;
        result = result*10 + (ch - '0');
    }
    if (minus1)
        return -result;
    else
        return result;
}

int a[MAXN];

int n;

void out() {
	for (int i = 1; i <= n; i++) {
		cout << a[i] << ' ';
	}
	cout << endl;
}

int main() {
n = readInt();
    for (int i = 1; i <= n; i++) {
    	a[i] = readInt();
    }
    int ans = 0;
    for (int i = 1; i <= n; i++) {
    	if (a[i] == i && a[i + 1] == i + 1)  {swap(a[i], a[i + 1]); ans++;}
    }
    //Aliya 58 drob 7 kv 18
    for (int i = 1; i <= n; i++) {
    	if (a[i] == i) {
    		if (i == 1) {
    		    swap(a[i], a[i + 1]);
    		} else {
				swap(a[i], a[i - 1]);    			
    		}
    		ans ++;
    	}
    	//out();
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int A,B;
    cin >> A >> B;
    if (A==B)
        cout << "Draw" << endl;
    else if (A==1)
        cout << "Alice" << endl;
    else if (B==1)
        cout << "Bob" << endl;
    else if (A<B)
        cout << "Bob" << endl;
    else if (A>B)
        cout << "Alice" << endl;
    

return 0;
}

Measured memory_bytes: 256
#include <iostream>/*{{{*/
#include <bits/stdc++.h>
#define REP(i, x) for(int i = 0; i < (int)(x); i++)
#define REPS(i,x) for(int i = 1; i <= (int)(x); i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define RFOR(i, m, n) for(int i = m;i >= n;i--)
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define FILL(x,y) memset(x,y,sizeof(x))
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define PB(a) push_back(a)
#define INF 999999999
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};/*}}}*/

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

  int a,b,c;
  cin >> a >> b >> c;

  if (a==b and b==c){
    cout << 1 << endl;
  }
  else if(a==b or b==c or c==a){
    cout << 2 << endl;
  }
  else{
    cout << 3 << endl;
  }

  return 0;
}


Measured memory_bytes: 256
use proconio::{fastout, input};

#[fastout]
fn main() {
    input!(s: char);

    println!(
        "{}",
        if s == 'A' {
            'T'
        } else if s == 'T' {
            'A'
        } else if s == 'C' {
            'G'
        } else {
            'C'
        }
    );
}


Measured memory_bytes: 2140
#include <bits/stdc++.h>
#define ll long long

using namespace std;

int main(){
    int n, count = 0;
    cin >> n;
    int p[n];
    for (int i = 0; i < n; i++){
        cin >> p[i];
    }
    for (int i = 0; i < n; i++){
        if(p[i] == i+1){
            swap(p[i], p[i+1]);
            count++;
        }
    }
    cout << count;

    return 0;
}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        String str = sc.next();
        StringBuffer strBuf = new StringBuffer(str);
        int q = sc.nextInt();
        for(int i = 0; i < q; i++){
            String order = sc.next();
            int x = sc.nextInt();
            int y = sc.nextInt()+1;
            if(order.equals("replace")){
                String repStr = sc.next();
                strBuf = strBuf.replace(x,y,repStr);
            }else if(order.equals("reverse")){
                StringBuffer revBuf = new StringBuffer(strBuf.substring(x,y));
                String revStr = revBuf.reverse().toString();
                strBuf = strBuf.replace(x,y,revStr);
            }else{
                System.out.println(strBuf.substring(x,y));
            }
        }
    }
}

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

int calc(int s, int d){
    if(s == 0 || s + (s & -s) > d){
        int res = 0;
        int t = s ^ d;
        for(int i = 0 ; i < 31 ; ++i){
            res += (t >> i & 1);
        }
        return res;
    }
    return 1 + calc(s + (s & -s), d);
}

int main(){
    int N;
    cin >> N;
    for(int n = 0 ; n < N ; ++n){
        int s, d;
        cin >> s >> d;

        int ans;
        if(s < 0 && d < 0){
            ans = calc(abs(d), abs(s));
        }else if(s < 0){
            ans = calc(0, abs(s)) + calc(0, d);
        }else{
            ans = calc(s, d);
        }

        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 3104