akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 2e5 + 5, mod = 1e9 + 7;


int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n, k;
    cin >> n >> k;
    vector<ll> pos, neg;
    bool found = 0;
    ll ans = 1;
    for(int i = 0; i < n; i++){
        int x;
        cin >> x;
        if(k == n) ans = ans * (x + mod) % mod;
        if(x > 0) pos.push_back(x);
        else if(x < 0) neg.push_back(-x);
        else found = 1;
    }
    if(k == n) return cout << ans, 0;
    n = pos.size();
    int  m = neg.size();
    if(n + m < k || n + m - m % 2 < k) return cout << 0, 0;
    if(n == 0 && k & 1){
        if(found) return cout << 0, 0;
        sort(neg.begin(), neg.end());
        ll ans = 1;
        for(int i = 0; i < k; i++){
            ans = ans * (-neg[i] + mod) % mod;
        }
        return cout << ans, 0;
    }
    sort(neg.rbegin(), neg.rend());
    sort(pos.rbegin(), pos.rend());
    int p1 = 0, p2 = 0;
    if(k & 1) ans = pos[0], p1 = 1;
    for(int i = k & 1; i < k; i+=2){
        ll best_pos = 0, best_neg = 0;
        if(p1 + 1 < n) best_pos = pos[p1] * pos[p1 + 1];
        if(p2 + 1 < m) best_neg = neg[p2] * neg[p2 + 1];
        if(best_pos >= best_neg){
            ans = ans * pos[p1] % mod;
            ans = ans * pos[p1 + 1] % mod;
            p1 += 2;
        }
        else{
            ans = ans * (-neg[p2] + mod) % mod;
            ans = ans * (-neg[p2 + 1] + mod) % mod;
            p2 += 2;
        }
    }
    cout << ans;



    return 0;
}


Measured memory_bytes: 5628
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#pragma warning(disable : 4996) //_CRT_SECURE_NO_WARNINGS

int main() {
	int A, B, C, D;
	scanf("%d%d%d%d",&A,&B,&C,&D);
	while (true) {
		C = C - B;
		if (C <= 0) {
			puts("Yes");
			break;
		}
		A = A - D;
		if (A <= 0) {
			puts("No");
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 1616
/*Lucky_Glass*/
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int SUM(int A)
{
	int ret=0;
	while(A)
		ret+=A%10,A/=10;
	return ret;
}
int main()
{
	int n,ans=1e9;
	scanf("%d",&n);
	for(int i=1;i<n;i++)
	{
		int A=i,B=n-i,tot=0;
		tot=SUM(A)+SUM(B);
		ans=min(ans,tot);
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 128
import sys
from collections import defaultdict
sys.setrecursionlimit(10 ** 7)

# 座標圧縮
# 座圧

N, M = map(int, input().split())
PY = [[int(x) for x in input().split()] for _ in range(M)]

PREFECTURE = defaultdict(list)
for p, y in PY:
    PREFECTURE[p].append(y)

for i in PREFECTURE.keys():
    ys = sorted(PREFECTURE[i])
    y_to_i = {y: i+1 for i, y in enumerate(ys)}
    PREFECTURE[i] = y_to_i

for p, y in PY:
    print('{:06}{:06}'.format(p, PREFECTURE[p][y]))


Measured memory_bytes: 59580
def menagerie_2():
	n = int(raw_input())
	ans = str(raw_input())

	def check_possibility(at, a):
		re = ['#']*len(a)
		re[0] = at[0]
		re[1] = at[1]
		for i in range(1, n-1):
			if a[i]=='o':
				if re[i]==1:
					re[i+1] = re[i-1]
				else:
					re[i+1] = re[i-1]*-1
			else:
				if re[i]==1:
					re[i+1] = re[i-1]*-1
				else:
					re[i+1] = re[i-1]

		c1 = False
		c2 = False
		if a[0]=='o':
			if re[0]==1 and (re[1]*re[-1]==1):
				c1 = True
			elif re[0]==-1 and (re[1]*re[-1]==-1):
				c1 = True
		else:
			if re[0]==1 and (re[1]*re[-1]==-1):
				c1 = True
			elif re[0]==-1 and (re[1]*re[-1]==1):
				c1 = True
		if a[-1]=='o':
			if re[-1]==1 and (re[0]*re[-2]==1):
				c2 = True
			elif re[-1]==-1 and (re[0]*re[-2]==-1):
				c2 = True
		else:
			if re[-1]==1 and (re[0]*re[-2]==-1):
				c2 = True
			elif re[-1]==-1 and (re[0]*re[-2]==1):
				c2 = True
		if c1 and c2:
			return re
		else:
			return None

	if check_possibility([1,1], ans) is not None:
		op = ['S' if x == 1 else 'W' for x in check_possibility([1,1], ans)]
		print''.join(op)
	elif check_possibility([1,-1], ans) is not None:
		op = ['S' if x == 1 else 'W' for x in check_possibility([1,-1], ans)]
		print''.join(op)
	elif check_possibility([-1,1], ans) is not None:
		op = ['S' if x == 1 else 'W' for x in check_possibility([-1,1], ans)]
		print''.join(op)
	elif check_possibility([-1,-1], ans) is not None:
		op = ['S' if x == 1 else 'W' for x in check_possibility([-1,-1], ans)]
		print''.join(op)
	else:
		print -1


if __name__ == "__main__":
	menagerie_2()

Measured memory_bytes: 6956
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>

using namespace std;

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

const int inf = 99999999;
const ll linf = 999999999999999999;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.end(), v.begin());
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

///////////////////////////////////////////////////////////////////////////



int main(){
    string s;
    cin >>s;

    rep(i,0,sz(s)/2){
        if(s[i] != s[sz(s)-i-1]){
            No;
            return 0;
        }
    }
    Yes;
	return  0;
}

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

#define MAX 10001

void CountingSort(short[],short[],int);

int main()
{
  unsigned short*A, *B;
  int C[MAX];
  int n;
  int i,j;

  scanf("%d", &n);

  A = malloc(sizeof(short) * (n + 1));
  B = malloc(sizeof(short) * (n + 1));

  for (i = 1; i < n + 1; i++)
    scanf("%hu", &A[i]);

  CountingSort(A,B,n);

  for (i = 1; i < n + 1; i++)
  {
    if (i > 1)
      printf(" ");

    printf("%d", B[i]);
  }

  printf("\n");

  free(A);
  free(B);

  return 0;
}

void CountingSort(short A[],short B[],int n)
{
  int i, j;
  int C[MAX];

  for (i = 0; i < MAX; i++)
    C[i] = 0;

  for (j = 1; j < n + 1; j++)
    C[A[j]]++;

  for (i = 1; i < MAX; i++)
    C[i] = C[i] + C[i - 1];

  for (j = n; j >= 1; j--)
  {
    B[C[A[j]]] = A[j];
    C[A[j]]--;
  }
} 


Measured memory_bytes: 9120
#include <iostream>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <algorithm>
#include <functional>
#include <cstring>
#include <limits.h>
#define FOR(i,k,n)  for (int i=(k); i<(int)(n); ++i)
#define REP(i,n)    FOR(i,0,n)
#define FORIT(i,c)	for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define SZ(i) ((int)i.size())
#define GI(i) (scanf("%d",&i))
#define GLL(i) (scanf("%lld",&i))
#define GD(i)  (scanf("%lf",&i))
#define PB          push_back
#define MP          make_pair
#define MT          make_tuple
#define GET0(x)     (get<0>(x))
#define GET1(x)     (get<1>(x))
#define GET2(x)     (get<2>(x))
#define ALL(X)      (X).begin(),(X).end()
#define LLMAX       (1LL<<60)
#define LLMIN       -(1LL<<60)
#define IMAX        (1<<30)
#define IMIN        -(1<<30)
typedef long long LL;
using namespace std;

int main(void){
    int K;GI(K);
    vector<LL> A(K);
    REP(i,K)GLL(A[i]);
    reverse(ALL(A));
    LL mi=2,ma=3;
    REP(i,K){
        LL mi2 = (mi+A[i]-1)/A[i]*A[i];
        LL ma2 = (ma-1)/A[i]*A[i] + A[i];
        mi = mi2;
        ma = ma2;
        // printf("mi=%lld ma=%lld\n",mi,ma);
        if(ma - mi <=0){
            printf("-1\n");
            return 0;
        }
    }
    printf("%lld %lld\n",mi,ma-1);
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cmath>
#include <iomanip>

using namespace std;

int main(int argc, char const *argv[])
{
    double A, B, H, M;
    double pi = 3.141592653589793;
    cin >> A >> B >> H >> M;
    double C = abs(0.5 * (60 * H - 11 * M));

    if (C == 0)
    {
        cout << abs(A - B) << endl;
        return 0;
    }else if (C == 180)
    {
        cout << A + B << endl;
        return 0;
    }
    
    if (C > 180)
    {
        C = 360 - C;
    }
    C = C / 180 * pi;
    double csq = pow(A, 2.0) + pow(B, 2.0) - 2 * A * B * cos(C);

    cout << setprecision(12) << pow(csq, 0.5) << endl;

    return 0;

}

Measured memory_bytes: 3664
#include<bits/stdc++.h>
#define llu unsigned long long
#define ll long long
#define INF 0x3f3f3f3f
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define to_lower(s) transform(s.begin(), s.end(), s.begin(), ::tolower);
#define to_upper(s) transform(s.begin(), s.end(), s.begin(), ::toupper);
const ll mod = 1e9 + 7;


using namespace std;

// scan vector
template <typename T> 
inline istream &operator>>(istream &in, vector<T> &a) {
    for(auto &x : a) in >> x;
    return in;
}
// print vector
template <typename T> 
inline ostream &operator<<(ostream &out, vector<T> &a) {
    for(auto &x : a) out << x <<" ";
    return out;
}
// scan pair
template <typename T, typename U> 
inline istream &operator>>(istream &in, pair<T,U> &a) {
    in >> a.first >> a.second; 
    return in;
}


const int V = 1200300;
bool visited[V];
vector<int> g[V];
ll max_return=0, max_level;
void dfs(int v, int level, map<int,int>& mp) 
{
    if (visited[v]) return;
    visited[v] = true;
    mp[level]++;
    for (auto to : g[v])
        dfs(to, level+1,mp);
}

int main()    
{
    #ifdef SANS
        freopen("ongoingin.txt","r",stdin);
        freopen("ongoingout.txt","w",stdout);
    #endif
    fast
    int t=1;
    // cin>>t;
    while(t--)
    {
        ll a,b,c,d;
        cin>>a>>b>>c>>d;
        cout<<max(max(a*c,b*d),max(a*d,b*c))<<endl;   
    }
    #ifdef SANS
        cout<<"\nTime Elapsed:"<<1.0*clock()/CLOCKS_PER_SEC <<"sec\n";
    #endif
}



Measured memory_bytes: 31788
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef vector<string> VS;
typedef priority_queue<int> PQ;
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 (b < a) { a = b; return 1; } return 0; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//priority_queue<int,vector<int>, greater<int> > q2;


struct UnionFind {
	VI par;
	UnionFind(int N) :par(N) {
		REP(i, N)par[i] = i;
	}
	int root(int x) {
		if (par[x] == x)return x;
		return par[x] = root(par[x]);
	}
	void unite(int x, int y) {
		int rx = root(x);
		int ry = root(y);
		if (rx == ry)return;
		par[rx] = ry;
	}
	bool same(int x, int y) {
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};

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

	string S; cin >> S;
	int cnt[26] = { 0 };
	REP(i, S.size()) {
		if (cnt[S[i] - 'a']++) {
			cout << "no" << endl;
			return 0;
		}
	}
	cout << "yes" << endl;
	return 0;
}



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

int main() {
	char S[20];
	string T;
	string p;
	string Q;
	int a = 0;
	int A = 0;
	int b = 0;
	int B = 0;
	int c = 0;
	int C = 0;
	int q, w, z;
	int n = 0;
	int x = 0;
	int y = 0;
	int ans = 0;
	cin >> x;
	if (x>=1200) {
		cout << "ARC";
	}
	else {
		cout << "ABC";
	}
}

Measured memory_bytes: 256
<?php
$n = trim(fgets(STDIN));
$a = explode(" ", trim(fgets(STDIN)));
$b = explode(" ", trim(fgets(STDIN)));

$count = 0;

for($i=0; $i<$n; $i++){
    if($a[$i] >= $b[$i]){
        $count += $b[$i];
    
    }elseif($a[$i] < $b[$i]){

        if(($b[$i] - $a[$i]) <= $a[$i+1]){
            $a[$i+1] -= ($b[$i] - $a[$i]);
            $count += $b[$i];
        }else{
            $count += $a[$i] + $a[$i+1];
            $a[$i+1] = 0;
        }
    }
}
echo $count;

?>

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

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

    let sum = w.iter().sum::<i32>();

    let mut curSum = w.iter().sum::<i32>();

    let mut result = std::i32::MAX;

    for i in 0..n {
        curSum -= w[i];

        let x = ((sum - curSum).abs() - curSum).abs();
        if result > x {
            result = x
        }
    }

    println!("{}", result)
}


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

int a[(int)2e5][11];

int main(){
    int x,y,z,n;
   cin >> x >> y >> z;
    n = y;
    y = x;
    x = n;
    
    n = z;
    z = x;
    x = n;
    
    cout << x << ' ' << y << ' ' << z;

}

    

		


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

using namespace std;

typedef long long ll;
typedef long double ld;

typedef bitset<2000 * 1000 + 7> bs;

int main() {
#ifdef AZINO777
    freopen("in", "r", stdin);
#endif
    bs x;
    x[0] = true;
    int n;
    cin >> n;
    int sm = 0;
    for (int i = 0; i < n; i++) {
        int xx;
        cin >> xx;
        sm += xx;
        x |= (x << xx);
    }
    for (int i = sm / 2; i >= 0; i--) {
        if (x[i]) {
            cout << sm - i << endl;
            return 0;
        }
    }
    assert(false);
}

Measured memory_bytes: 1152
card = [list(map(int, input().split())) for i in range(3)]
n = int(input())
chk = [[0] * 3 for i in range(3)]

for i in range(n):
    num = int(input())
    for j in range(3):
        for k in range(3):
            if num == card[j][k]:
                chk[j][k] = 1

if any([all([chk[0][0], chk[0][1], chk[0][2]]),
        all([chk[1][0], chk[1][1], chk[1][2]]),
        all([chk[2][0], chk[2][1], chk[2][2]]),
        all([chk[0][0], chk[1][0], chk[2][0]]),
        all([chk[0][1], chk[1][1], chk[2][1]]),
        all([chk[0][2], chk[1][2], chk[2][2]]),
        all([chk[0][0], chk[1][1], chk[2][2]]),
        all([chk[0][2], chk[1][1], chk[2][0]])
        ]):
    print("Yes")
else:
    print("No")

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

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

  if (a>b) {
    cout << "a > b" << endl;
  } else if (a == b) {
    cout << "a == b" << endl;
  } else {
    cout << "a < b" << endl;
  }

  return 0;

}


Measured memory_bytes: 3076
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define sz(x) int(x.size())
typedef long long ll;
const int inf = 100100100;

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

  string t = "abcdefghijklmnopqrstuvwxyz";

  vector<int> a(26,inf);
  rep(i,n){
    string u;
    cin >> u;
    vector<int> b(26,0);
    rep(j,u.size()){
      rep(k,26){
        if(u[j] == t[k]) b[k]++;
      }
    }
    rep(j,26){
      a[j] = min(a[j],b[j]);
    }
  }
  rep(i,26){
    rep(j,a[i]) cout << t[i];
  }
  cout << endl;
}



Measured memory_bytes: 3612
A, B , M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ans = min(a) + min(b)
for _ in range(M):
    x, y, c = map(int,input().split())
    tmp_ans = a[x - 1] + b[y - 1] - c
    if tmp_ans < ans:
        ans = tmp_ans
print(ans)

Measured memory_bytes: 18612
import sys
from collections import deque

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n, m = map(int, input().split())
    edge = [[] for _ in range(n)]
    edge_r = [[] for _ in range(n)]
    for _ in range(n - 1 + m):
        a, b = map(int, input().split())
        edge[a - 1].append(b - 1)
        edge_r[b - 1].append(a - 1)

    visited = [False] * n
    visited[0] = True
    que = deque([0])
    while que:
        v = que.popleft()
        if len(edge_r[v]) == 0:
            root = v
            break
        for u in edge_r[v]:
            if not visited[u]:
                visited[u] = True
                que.appendleft(u)

    cnt = [len(edge_r[i]) for i in range(n)]
    res = [[] for _ in range(n)]
    res[root].append(0)
    que = deque([root])
    while que:
        v = que.popleft()
        for u in edge[v]:
            if cnt[u] > 1:
                cnt[u] -= 1
            else:
                cnt[u] = 0
                que.appendleft(u)
                res[u].append(v + 1)

    for i in res:
        print(*i)


if __name__ == '__main__':
    resolve()


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

int main() {
  int N, K;
  cin >> N >> K;
  
  int num = 1;
  
  for (int i = 0; i < N; i++){
    if (num * 2 < num + K){
      num *= 2;
    }
    else {
      num += K;
    }
  }
  cout << num << endl;
}



Measured memory_bytes: 256
N = int(input())
s1 = input()
s2 = input()
p = 0
ans = 1
while p < N:
      # 
      if s1[p] == s2[p]:
            if p == 0:
                  ans *= 3
            else:
                  # 手前が縦なら2通り選べる
                  if s1[p-1] == s2[p-1]:
                        ans *= 2
                  # 手前が横なら残っている色しか選べない
                  else:
                        ans *= 1
                  
            p += 1      
      elif s1[p] != s2[p]:
            if p == 0:
                  ans *= 6
            else:
              # 手前が縦の場合、上下の入れ替えで2通り
              if s1[p-1] == s2[p-1]:
                ans *= 2
              elif s1[p-1] != s2[p-1]:
                # 手前が横の場合、3通り？
                ans *= 3
            p += 2

print(ans % (10**9+7))      


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

#define REP(i, n ,N) for(ll i = (n); i < (N); i++)
#define RREP(i, n ,N) for(ll i = (N-1); i >= (n); i--)
#define p(s) cout<<(s)<<endl
#define p2(a, b) cout<<(a)<<" "<<(b)<<endl
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
ll inf = 1e18;

ll N;
ll A[16];
ll x[16][16], y[16][16];
ll ans;
int main(){
	cin >> N;
	REP(i,0,N){
		cin >> A[i];
		REP(j,0,A[i]){
			cin >> x[i][j] >> y[i][j];
			x[i][j]--;
		}
	}
	REP(mask,1,1LL<<N){
		bool ok = true;
		ll cnt = 0;
		REP(i,0,N){
			if((1LL << i) & mask){

				cnt++;
				REP(j,0,A[i]){
					if(((mask & (1LL << x[i][j])) > 0) != y[i][j]){
						ok = false;
						break;
					}
				}
				if(!ok){
					break;
				}
			}

		}
		if(ok){
			ans = max(ans, cnt);
		}
	}
	p(ans);

	return 0;
}

Measured memory_bytes: 256
def main():
    n = int(input())
    
    z = []
    w = []

    for _ in range(n):
        x,y = tuple(map(int,input().split()))
        z.append(x+y)
        w.append(x-y)

    print(max(max(z)-min(z),max(w)-min(w)))

if __name__ == "__main__":
    main()

Measured memory_bytes: 24860
function Main(input) {
  const max = Math.max(input[0], input[1]);
  const min = Math.min(input[0], input[1]);

  var okashi;
  for (var i = 1;; i++) {
    okashi = max * i;

    if (okashi % min === 0) {
      console.log(okashi);
      return;
    }
  }
}

Main(require("fs").readFileSync("/dev/stdin", "utf8").trim().split(" ").map(Number));

Measured memory_bytes: 21064
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(void)
{
    int i, j, k, n;
    scanf("%d%d%d", &i, &j, &k);
    n = j;
    j = i;
    i = k;
    k = n;
    printf("%d %d %d\n", i, j, k);
    return 0;
}

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

#define FOR(i, m, n) for(int (i) = (m); (i) < (n); (i)++)
#define FORN(i, m, n) for(int (i) = (m); (i) <= (n); (i)++)
#define FORR(i, m, n) for(int (i) = (m); (i) >= (n); (i)--)
#define rep(i, n) FOR(i, 0, n)
#define repn(i, n) FORN(i, 1, n)
#define repr(i, n) FORR(i, n, 0)
#define repnr(i, n) FORR(i, n, 1)
#define co(n) cout << (n) << endl
#define cosp(n) cout << (n) << ' '
#define setp(n) cout << fixed << setprecision(n);
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
typedef long long ll;
typedef pair<int, int> P;

const ll INF = 1e9+1;
const ll LINF = 1e18+1;
//const ll MOD = 1e9+7;
const ll MOD = 998244353;
const double PI = acos(-1);
const double EPS = 1e-9;
const int MAX_N = 1e5;

void solve(){
	int n;
	cin >> n;
	vector<list<int> > tree(n);

	rep(i, n-1){
		int a, b;
		cin >> a >> b;
		a--; b--;
		tree[a].pb(b);
		tree[b].pb(a);
	}

	vector<int> c(n);
	rep(i, n) cin >> c[i];
	sort(all(c));
	ll ans = 0;
	rep(i, n-1) ans += c[i];
	co(ans);

	vector<int> cost(n);
	queue<int> q;
	rep(i, n) if(tree[i].size() == 1) q.push(i);
	int cnt = 0;
	while(!q.empty()){
		int a = q.front(); q.pop();
		cost[a] = c[cnt++];
		if(!tree[a].empty()){
			int b = tree[a].front();
			tree[a].remove(b);
			tree[b].remove(a);
			if(tree[b].size() == 1) q.push(b);
		}
	}

	rep(i, n) cosp(cost[i]);
	cout << endl;
}

int main(void){
	solve();

	return 0;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
 
const double pi = 3.141592653589793238462643383279;
using namespace std;
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
 
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
 
//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007
 
 
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
 
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
 
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)

//ここから編集

ll f(ll b, ll n){
  if(n < b) return n;
  return f(b, n/b) + n%b;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(5);
  
  ll n, s; cin >> n >> s;

  if(n < s) cout << -1 << endl;
  else if(n == s) cout << n + 1 << endl;
  else{

  ll t = n-s;
  set<ll> st;
  for(ll i=1; i*i<=t; i++){
    if(t%i == 0){
      st.insert(i);
      st.insert(t/i);
    }
  }
  for(auto e: st){
    ll b = e+1;
    if(f(b, n) == s){
      cout << b << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  }
  return 0;
}

Measured memory_bytes: 3740
#include <bits/stdc++.h>
using namespace std;
int solve(int i, int n, vector<int>& A){
    if(n==0)return 1;
    else if(i==A.size() || n<0) return 0;
    return max(solve(i+1, n-A[i], A), solve(i+1, n, A) );
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,m,m_i;
    cin >> n;
    vector<int> A(n);
    for(int i=0;i<n;i++) cin >> A[i];
    cin >> m;
    for(int i=0;i<m;i++){
        cin >> m_i;
        if(solve(0,m_i,A)) cout << "yes" << endl;
        else cout << "no" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3220
#include <iostream>
#include <cstdio>
#include <map>
#include <deque>
using namespace std;

long long d[100000];
long long h[100000];
long long s[100000];
int main(){
	long long N,H,mx;
	scanf("%lld%lld",&N,&H);
	mx = H;
	for(int i = 0 ; i < N-1 ; i++){
		scanf("%lld%lld",&d[i],&h[i]);
		s[i+1] = s[i] + d[i];
	}
	
	int ans = 0;
	deque<int> Q;
	for(int i = 0 ; i < N-1 ; i++){
		while( Q.size() && h[Q.back()] <= h[i]) Q.pop_back();
		Q.push_back(i);
		while( Q.size() && s[i] - s[Q.front()] > mx) Q.pop_front();
		if( H <= d[i] ){
			for(int j = 0 ; j < Q.size() ; j++){
				long long heal_max = max(0ll, mx - (s[i] - s[Q[j]]) - H );
				long long need = d[i] - H + 1;
				long long use = min(need,heal_max) / h[Q[j]];
				H += use * h[Q[j]];
				ans += use;
				if( H > d[i] ) break;
				
				if( j+1 >= Q.size() || mx - (s[i] - s[Q[j]]) - H >= h[Q[j+1]] ){
					ans++;
					H = min( H + h[Q[j]], mx - (s[i] - s[Q[j]]) );
				}
				if( H > d[i] ) break;
			}
		}
		H -= d[i];
		if( H <= 0 ){
			cout << -1 << endl;
			return 0;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3572
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <vector>

#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define STRS(i,str) for(int i=0;(str)[i];i++)
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define MAX3(a,b,c) ((a)>(b)?(a)>(c)?(a):(c):(b)>(c)?(b):(c))
#define MIN3(a,b,c) ((a)<(b)?(a)<(c)?(a):(c):(b)<(c)?(b):(c))
#define MED(a,b,c) ((a)<(b)?(a)>(c)?(a):(b)<(c)?(b):(c):(a)>(c)?(b)<(c)?(c):(b):(a))
#define RANGE(a,b) ((a)>(b)?(a)-(b):(b)-(a))
#define RANGE3(a,b,c) ((a)>(b)?(b)>(c)?(a)-(c):(c)>(a)?(c)-(b):(a)-(b):(b)>(c)?(c)>(a)?(b)-(a):(b)-(c):(c)-(a))
#define MAXI(a,b) if(a<b)a=b;
#define MINI(a,b) if(a>b)a=b;
#define BEGINFOR(a,b,c,d,e,f,g,h,i) a;goto i##_6;i##_2:c;goto i##_6;i##_3:h;goto i##_7;i##_4:d;goto i##_8;i##_5:f;goto i##_8;i##_6:if(b)goto i##_4;else goto i##_9;i##_7:if(g)goto i##_5;else goto i##_1;i##_8:if(e)goto i##_2;else goto i##_3;i##_9:
#define CONTINUE(i) goto i##_3
#define BREAK(i) goto i##_1
#define ENDFOR(i) goto i##_3;i##_1:

using ull = unsigned long long;

int main(void) {
	int n;
	ull a[4] = { 1, 1, 1, 0 }, b[4] = { 1, 0, 0, 1 };
	scanf("%d", &n);
	n--;
	while (n) {
		if (n & 1) {
			ull t[4];
			t[0] = b[0] * a[0] + b[1] * a[2];
			t[1] = b[0] * a[1] + b[1] * a[3];
			t[2] = b[2] * a[0] + b[3] * a[2];
			t[3] = b[2] * a[1] + b[3] * a[3];
			b[0] = t[0];
			b[1] = t[1];
			b[2] = t[2];
			b[3] = t[3];
		}
		ull t[4];
		t[0] = a[0] * a[0] + a[1] * a[2];
		t[1] = a[0] * a[1] + a[1] * a[3];
		t[2] = a[2] * a[0] + a[3] * a[2];
		t[3] = a[2] * a[1] + a[3] * a[3];
		a[0] = t[0];
		a[1] = t[1];
		a[2] = t[2];
		a[3] = t[3];
		n >>= 1;
	}
	printf("%llu", b[0] + b[1] * 2);
}

Measured memory_bytes: 128
#include<iostream>
using namespace std;
static const int A_MAX = 1000;

int main(){
  int N;
  int A;
  int flag = 1;
  cin >> N;
  for(int i = 0;i<N;i++){
    cin >> A;
    if(A % 2 == 0){
      if ((A % 3 != 0) && ((A % 5 != 0))){
        flag = 0;
        break;
      }
    }
  }
  
  if(flag){
    cout << "APPROVED" << endl;
  }
  else{
    cout << "DENIED" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
import bisect
n = int(input())
s = list(input())
b = [0]*(n+1)
c = [s.count(".")]*(n+1)
a = []
a.append(c[0])
for i in range(n):
    if s[i] == "#":
        b[i+1] = b[i] + 1
        c[i+1] = c[i]
    else:
        c[i+1] = c[i] - 1
        b[i+1] = b[i]
    a.append(b[i+1] + c[i+1])
if "." not in s:
    a.append(0)
elif "#" not in s:
    a.append(0)
print(min(a))

Measured memory_bytes: 22308
#pragma comment(linker,"/stack:16777216")
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<list>
#include<stack>
#include<queue>
#include<deque>
#include<functional>
#include<utility>
#include<algorithm>
#include<sstream>
#include<cstring>
#include<cmath>
#include<cctype>
#include<exception>
#include<climits>
#include<cfloat>
#include<iomanip>
#include<bitset>
#include<streambuf>
#include<cstdlib>
#include<ctime>
//#include"functions.h"
//#include"highprecision.h"
#define pb push_back
#define pf push_front
#define ppb pop_back
#define mp make_pair
#define np next_permutation
#define fi first
#define sc second
#define vi vector<int>
#define vll vector<long long>
#define vvi vector<vector<int> >
#define vpi vector<pair<int,int> >
#define pii pair<int,int>
#define pll pair<long long,long long>
#define pff pair<float,float>
#define pdd pair<double,double>
#define psi pair<string,int>
#define pis pair<int,string>
#define ppi pair<pii,int>
#define pdi pair<pii,pii>
#define LN 84757
#define INF 1e9
#define LLINF 1e18
#define MAXINT 0x7fffffff
#define MAXLL 0x7fffffffffffffff
#define EPS 1e-5
#define DEPS 1e-9
#define LDEPS 1e-13
#define MOD 1000000007
#define E 2.7182818284
#define PI 3.1415926535
#define rep(a,b) for(int a=0;a<b;a++)
#define rep(a,b) for(int a=0;a<b;a++)
#define forn(a,n) for(int a=1;a<=n;a++)
#define forr(a,n) for(int a=n;a>=1;a--)
#define repn(a,n,p) for(int a=0;a<n;a+=p)
#define repr(a,n) for(int a=n-1;a>=0;a--)
#define foreach(a,b) for(__typeof(b.begin())a=b.begin();a!=b.end();a++)
#define fillemp(a) memset(a,0,sizeof(a))
#define fillinf(a) memset(a,0x3f,sizeof(a))
#define frestream freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define stdf(a,b) freopen(a,"r",stdin);freopen(b,"w",stdout);
#define inputf(a) freopen(a,"r",stdin);
#define outputf(a) freopen(a,"w",stdout);
#define sz(a) a.size()
#define all(a) a.begin(),a.end()
#define MOD 1000000007
typedef long long ll;
typedef long double ld;
using namespace std;

ll a[200010];
int main(){
	int n;
	ll ans=0ll;
	cin>>n;
	rep(i,n){
		cin>>a[i];
	}
	forn(i,n-1){
		if(a[i]<a[i-1]){
			ans+=a[i-1]-a[i];
			a[i]=a[i-1];
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 5192
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/STACK:108777216")
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <string>
#include <map>
#include <set>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;
 
int const MAX_N = 128 * 1024;

void first() {
	cout<<"Alice";
	exit(0);
}

void second() {
	cout<<"Borys";
	exit(0);
}

int main() {
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
 
    int n,a,b;
	cin>>n>>a>>b;

	if ((b-a-1)%2==0)
		second();

	first();
    return 0;
}  


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = (s); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i = (n); i >= 0; i--)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    string S; cin >> S;
    S.resize(60,' ');
    bool ok = true;
    int i = 0;

    if (S[i] == 'A') i++;

    if (S.substr(i,3) != "KIH") ok = false;
    i += 3;

    if (S[i] == 'A') i++;

    if (S.substr(i,1) != "B") ok = false;
    i++;

    if (S[i] == 'A') i++;

    if (S.substr(i,1) != "R") ok = false;
    i++;

    if (S[i] == 'A') i++;
    if (S[i] != ' ') ok = false;

    CFYN(ok)


    return 0;
}

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

w = list(map(int,input().split()))

ans = 1000000
a = 0
b = 0

for i in range(n-1):
	for j in range(i+1):
		#print('--j---')
		#print(j)
		a = a + w[j]
		#print(a)
	for k in range(i+1,n):
		#print('--k---')
		#print(k)
		b = b + w[k]
		#print(b)
	if abs(a-b) < ans :
		ans = abs(a-b)
	a = 0
	b = 0

print(ans)


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

vector<string> split_naive(string &s, char delim) {
    vector<string> elems;
    string item;
    for (char ch: s) {
        if (ch == delim) {
            if (!item.empty())
                elems.push_back(item);
            item.clear();
        }
        else {
            item += ch;
        }
    }
    if (!item.empty())
        elems.push_back(item);
    return elems;
}
typedef struct Proc {
     string name;
     int time;
} proc;

vector<proc> schedule(deque<proc> &p, int q) {
    int use_time = 0;
    vector<proc> end;
    while (!p.empty()) {
        int remain = q;
        while (remain > 0 && !p.empty())
        {
            proc first = p.front();
            p.pop_front();
            if (first.time > remain)
            {
                first.time -= remain;
                use_time += remain;
                remain = 0;
                p.push_back(first);
            }
            else
            {
                remain = 0;
                use_time += first.time;
                proc n = {first.name, use_time};
                end.push_back(n);
            }
        }
    }
    return end;
}

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

    deque<proc> data;
    for (int i=0; i < n; i++) {
        string key;
        int val;
        cin >> key >> val;
        proc p = {key, val};
        data.push_back(p);
    }

    vector<proc> p = schedule(data, q);
    for (int i=0; i < p.size(); i++) {
        cout << p[i].name << " " << p[i].time << endl;
    }

    return 0;
}


Measured memory_bytes: 6968
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
#define rop(i,n) for(int i=1;i<n+1;i++)

using namespace std;
using std::swap;

vector<long long int> p;
vector<long long int> q;



int main() {
	int a;
	string s;
	cin >> a>>s;
	if (a >= 3200)cout << s << "\n";
	else cout << "red" << "\n";
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

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

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

    public static void main(String[] args) {
        FastReader in = new FastReader();
        long a = in.nextLong();
        long b = in.nextLong();
        long c = in.nextLong();
        long k = in.nextLong();
        long sum;
        long rem = 0;
        if(a<=k){
            rem = k-a;
            sum = a*1;
        }
        else {
            sum = k;
        }
        if(rem>0){
            if(b<=rem){
                rem = rem-b;
            }
        }
        if(rem>0){
            sum = sum + rem*(-1);
        }
        System.out.println(sum);
    }
}

Measured memory_bytes: 32652
n, m = map(int, input().split())

s = [-1 for i in range(n + 1)]
s[0] = 1
s[1] = 1

for i in range(m):
    a = int(input())
    s[a] = 0

for i in range(2, len(s)):
    if s[i] == 0:
        continue
    else:
        s[i] = (s[i - 1] + s[i - 2]) % 1000000007

print(s[n])


Measured memory_bytes: 7064
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m,j,i,k=0,sum=0;
    cin>>n;
    int a[n],b[10000];
    for(i=0; i<n; i++)
    {
        cin>>a[i];
    }
    for(i=1; i<=100; i++)
    {
        for(j=0; j<n; j++)
        {
            m = (a[j]-i)*(a[j]-i);
            sum+=m;
        }
        b[k] = sum;
        k++;
        sum=0;
    }
    sort(b,b+k);
    cout<<b[0];
}


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

int main()
{
  int64_t N;
  cin >> N;
  vector<int64_t> C(100000, 0);
  for (int x = 1; x <= 100; x++)
  {
    for (int y = 1; y <= 100; y++)
    {
      for (int z = 1; z <= 100; z++)
      {
        int64_t n = x * x + y * y + z * z + x * y + y * z + z * x;
        C.at(n)++;
      }
    }
  }
  for (int i = 1; i <= N; i++)
  {
    cout << C.at(i) << endl;
  }
}


Measured memory_bytes: 4028
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
#include <complex>
#include <cstdio>
#include <list>
#include <bitset>

//< in.txt > out.txt
using namespace std;
//std::ios::sync_with_stdio(false);
//std::cin.tie(0);
const long long MOD = 1e9+7;
const long long INF = 1e18;
typedef long long LL;
typedef long double LD;
//typedef boost::multiprecision::cpp_int bigint;
typedef pair<LL, LL> PLL;
typedef pair<LD, LL> pdl;
typedef pair<LD, LD> pdd;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef unsigned long long ULL;

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	int N;
	cin >> N;
	VI A(N);
	for (int i = 0; i < N; i++)cin >> A[i];
	VI count(2e5 + 1, 0);
	for (int i = 0; i < N; i++)count[A[i]]++;
	LL all = 0;
	for (int i = 0; i <= 2e5; i++) {
		all += (LL)count[i] * (count[i] - 1) / 2;
	}
	for (int i = 0; i < N; i++) {
		cout << all - (count[A[i]] - 1) << "\n";
	}
	return 0;
}

Measured memory_bytes: 4760
n,y  = map(int, input().split())

ans = "-1 -1 -1"
for i in range(n+1):
  for j in range(n-i+1):
    k = n-i-j
    if 10000*i+5000*j+1000*k == y:
      ans = str(i)+" "+str(j)+" "+str(k)
      break

print(ans)

Measured memory_bytes: 9136
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const long long INF= 1e+18+1;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
int main(){
  ll n;cin>>n;
  vl c(n);
  rep(i,n)cin>>c[i];
  vl dp(n+1);
  rep(i,n+1)dp[i]=0;
  map<ll,ll>M;
  dp[0]=1;
  for(ll i=1;i<=n;i++){
    if(i!=1&&c[i-1]==c[i-2]){
      dp[i]=dp[i-1];
      continue;
    }
    dp[i]=M[c[i-1]]+dp[i-1];
    dp[i]%=MOD;
    M[c[i-1]]=dp[i];
  }
  //rep(i,n+1)cout<<dp[i]<<" ";
  cout<<dp[n]<<endl;
}
    

Measured memory_bytes: 15872
import java.util.*;

class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n=sc.nextInt();
        System.out.println(count(0,n));
        
    }
    static int count(long num,long n) {
    	int ans=0;
    	
    	if(num<=n&&String.valueOf(num).contains("3")&&String.valueOf(num).contains("5")&&String.valueOf(num).contains("7")) {
    		ans++;
    		
    	}
    	if(num<=n) {
    		ans+=count(num*10+3,n)+count(num*10+5,n)+count(num*10+7,n);
    		
    	}
    	return ans;
    
    
    }
}


Measured memory_bytes: 29524
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define fi first
#define se second
#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 rep11(i, n) for (int i = 1; i < (int)(n); ++i)
#define rep0(i, n) for (int i = 1; i <= (int)(n); ++i)
#define repo(i, o, n) for (int i = o; i < (int)(n); ++i)
#define repm(i, n) for (int i = (int)(n)-1; i >= 0; --i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1002000007
#define INF LO
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}



int main(){
    long long n,a,b,c,d,e;
    cin>>n;
    cin>>a;
    cin>>b;
    cin>>c;
    cin>>d;
    cin>>e;
    long long v[5];
    v[0]=a;
    v[1]=b;
    v[2]=c;
    v[3]=d;
    v[4]=e;
    long long ans=1e+18;
    rep(i,5){
        ans=min(v[i],ans);
    }
    
    cout<<((n-1)/ans)+5<<endl;
   
}
    


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

using namespace std;

const int dx[] = { -1, 0, 1, 0 };
const int dy[] = { 0, -1, 0, 1 };

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

	int h, w;
	cin >> h >> w;

	vector<string> s(h);
	for(int i = 0; i < h; ++i) {
		cin >> s[i];
	}

	queue<int> q;
	vector<vector<int> > d(h, vector<int> (w, -1));

	for(int i = 0; i < h; ++i) {
		for(int j = 0; j < w; ++j) {
			if(s[i][j] == '#') {
				q.emplace(i);
				q.emplace(j);
				d[i][j] = 0;
			}
		}
	}

	while(!q.empty()) {
		int x = q.front();
		q.pop();
		int y = q.front();
		q.pop();

		for(int i = 0; i < 4; ++i) {
			int xx = x + dx[i];
			int yy = y + dy[i];
			if(0 <= xx && xx < h && 0 <= yy && yy < w && d[xx][yy] == -1) {
				d[xx][yy] = d[x][y] + 1;
				q.emplace(xx);
				q.emplace(yy);
			}
		}
	}

	int ans = 0;
	for(int i = 0; i < h; ++i) {
		for(int j = 0; j < w; ++j) {
			ans = max(ans, d[i][j]);
		}
	}

	cout << ans << '\n';

	return 0;
}


Measured memory_bytes: 13456
#include<stdio.h>
int main (void){
  int n,i;
  long long j,k,a[100000],ans,aaa=1000000000000000000;
  ans=1;
  scanf("%d",&n);
  
  for(i=0;i<n;i++){
    scanf("%lld",&a[i]);
    if(a[i]==0){ans=0;}
  }

  if(ans!=0){
    for(i=0;i<n;i++){
      k=aaa%ans;
      j=(aaa-k)/ans;
      
      if(j<a[i]){ans=-1;break;}
    
      ans=ans*a[i];
    }
  }
  printf("%lld",ans);
  return 0;
}

Measured memory_bytes: 2476
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var n string
	fmt.Scan(&n)

	ans := 0
	only9 := true
	for i := 1; i < len(n); i++ {
		if n[i] != '9' {
			only9 = false
		}
		ans += 9
	}
	a, _ := strconv.Atoi(n[0:1])
	if len(n) > 1 && !only9 {
		a--
	}
	fmt.Println(ans + a)
}


Measured memory_bytes: 512
from sys import stdin
s = stdin.readline().rstrip()
n = len(s)
total = 0
for i in range(2**(n-1)):
    li = []
    for j in range(n-1):
        if ((i >> j) & 1):
            li.append(j)
    point = 0
    for k,l in enumerate(s):
        point *= 10
        point += int(l)
        if k in li:
            total += point
            point = 0
    total += point
print(total)

Measured memory_bytes: 3064
n=int(input())
p=list(map(int,input().split()))
cnt=0

for i in range(1,n-1):
    low=min(p[i-1],p[i],p[i+1])
    heigh=max(p[i-1],p[i],p[i+1])
    if low<p[i]<heigh:
        cnt+=1
print(cnt)

Measured memory_bytes: 3060
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.Set;
import java.util.TreeMap;
import java.util.TreeSet;

class Item implements Comparable<Item> {
	int x;
	int y;
	
	public Item(int x, int y) {
		this.x = x;
		this.y = y;
	}
	
	@Override
	public int compareTo(Item o) {
		int res = Integer.compare(x, o.x);
		if (res == 0) {
			res = Integer.compare(y, o.y);
		}
		return res;
	}
}

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		List<Item> list = new ArrayList<>();
		for (int i = 0; i < n; i++) {
			list.add(new Item(sc.nextInt(), sc.nextInt()));
		}
		Collections.sort(list);
		for (int i = 0; i < list.size(); i++) {
			System.out.println(list.get(i).x + " " + list.get(i).y);
		}
	}
}



Measured memory_bytes: 112376
//Optional FAST

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,fma,abm,mmx,avx,avx2,tune=native")

//Required Libraries

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

//Required namespaces

using namespace std;
using namespace __gnu_pbds;

//Required defines

#define endl '\n'

#define READ(X) cin>>X;
#define READV(X) long long X; cin>>X;
#define READAR(A,N) long long A[N]; for(long long i=0;i<N;i++) {cin>>A[i];}
#define rz(A,N) A.resize(N);
#define sz(X) (long long)(X.size())
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define trav(x,A) for(auto &x:A)
#define FORI(a,b,c) for(long long a=b;a<c;a++)
#define FORD(a,b,c) for(long long a=b;a>c;a--)

//Required typedefs

typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
typedef vector<int> veci;
typedef vector<long long> vecl;

//Required Constants

const long long inf=(long long)1e18;
const long long MOD=(long long)(1e9+7);
const long long INIT=(long long)(1e6+1);

//Required Functions

ll power(ll x,ll y) 
{ 
	if (y == 0) 
		return 1; 
	ll p = power(x, y/2) % MOD; 
	p = (p * p) % MOD; 
  
	return (y%2 == 0)? p : (x * p) % MOD; 
}
ll modInverse(ll a) 
{ 
   return power(a,MOD-2); 
   
}

//Work

int main()
{
	#ifndef ONLINE_JUDGE
	if (fopen("INPUT.txt", "r"))
	{
		freopen ("INPUT.txt" , "r" , stdin);
		//freopen ("OUTPUT.txt" , "w" , stdout);
	}
	#endif
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	clock_t clk;
	clk = clock();
//-----------------------------------------------------------------------------------------------------------//

	string S;
	cin>>S;
	if(S[2]==S[3] && S[4]==S[5])
	{
		cout<<"Yes"<<endl;
	}
	else
	{
		cout<<"No"<<endl;
	}
	

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


	clk = clock() - clk;
	cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << endl;

	return 0;
}

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

int main()
{
  std::string S, T, U;
  int A, B;
  std::cin >> S >> T;
  std::cin >> A >> B;
  std::cin >> U;
  if (S==U) A--;
  else B--;
  std::cout << A << " " << B << std::endl;
  return 0;
}

Measured memory_bytes: 3564
#include<bits/stdc++.h>
using namespace std;
int main() {
	int A, B, K; cin >> A >> B >> K;
	if(K * 2 > B - A) {
		for (int i = A; i <= B; i++)
		{
			cout << i << endl;
		}
	}
	else {
		for (int i = A; i < A + K; i++)
		{
			cout << i << endl;
		}
		for (int i = B - K + 1; i <= B; i++)
		{
			cout << i << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <iostream>
#define maxn 100009
using namespace std;
long long fact[maxn];
const int MOD = 1e9 + 7;
int main(){
	fact[0] = 1;
	for(int i = 1; i < maxn; i++)
		fact[i] = fact[i - 1] * i % MOD;
	int n, m;
	cin >> n >> m;
	if(abs(n- m) >= 2){
		puts("0");
		return 0;
	}
	else if(abs(n - m) == 1){
		cout << fact[n] * fact[m] % MOD << endl;
	}
	else{
		cout << 2 * fact[n] * fact[m] % MOD << endl;
	}
	return 0;
}

Measured memory_bytes: 1024