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

int main() {
  int n;
  int min = 0;
  int sum = 0;
  cin >> n;

  int x[n];

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

  sort(x, x + n);

  for(int i = x[0]; i < x[n - 1]; i++){
    for(int j = 0; j < n; j++){
      sum += (x[j] - i) * (x[j] - i);
    }

    if(i == x[0]){
      min = sum;
    }
    else if(min > sum){
      min = sum;
    }

    sum = 0;
  }

  cout << min << endl;

  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	int i,n;
	int data[100];
	scanf("%d", &n);
	for(i=0; i<n; i++){
		scanf("%d", &data[i]);
	}
	for(i=n; i>0; i--){
		if(i<n){
			printf(" ");
		}
		printf("%d", data[i-1]);
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <cmath>
#include <iomanip>
#include <numeric>
#include <functional>
#include <queue>
#include <tuple>

using namespace std;

using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using ll = long long;
using vll = vector<ll>;
using pii = pair<int, int>;
using vb = vector<char>;
using vvb = vector<vb>;

#define REP(i, a, b) for (int i = a; i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(),(x).end()
#define iter(c) __typeof((c).begin())
#define tr(i, c) for (iter(c) i = (c).begin(); i != (c).end(); i++)
#define mp(a, b) make_pair(a,b)

#define fi first
#define sn second
#define decpii(p) p.fi--,p.sn--;


#ifdef LOCAL
#define dump(c) cerr << "> " << #c << " = " << (c) << endl;
#define dumpn(c) cerr << "> " << #c << " = " << (c) << ", ";
#else
#define dump(c) ;
#define dumpn(c) ;
#endif


template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
    return os << '(' << p.first << ',' << p.second << ')';
}

template<typename T>
ostream &operator<<(ostream &os, const vector<T> &a) {
    os << '[';
    rep(i, (int) a.size())os << (i ? " " : "") << a[i];
    return os << ']';
}


int dxf[] = {1, 0, -1, 0};
int dyf[] = {0, -1, 0, 1};

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

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

inline vi uni(vi &vec) {
    sort(vec.begin(), vec.end());
    vec.erase(std::unique(vec.begin(), vec.end()), vec.end());
    return vec;
}

struct ____ {
    ____() {
        cin.tie(0);
        ios::sync_with_stdio(0);
        cout << fixed << setprecision(20);
    };
} ________;

int solve() {
    int N, M;
    cin >> N >> M;
    vector<int> a(M), b(M);
    for (int i = 0; i < M; ++i) {
        cin >> a[i] >> b[i];
        --a[i],--b[i];
    }

    vi nlist(N);
    iota(all(nlist), 0);
    int res = 0;
    do {
        if(nlist[0] != 0)
            continue;

        REP(t, 1, N) {
            bool ok = false;
            rep(i, M) {
                if ((a[i] == nlist[t - 1] && b[i] == nlist[t]) ||
                    (b[i] == nlist[t - 1] && a[i] == nlist[t])) {
                    ok = true;
                }
            }
            if (!ok) {
                break;
            }

            if (t == N - 1)
                res++;
        }
    } while (next_permutation(all(nlist)));

    return res;
}

int main() {
    cout << solve() << endl;
    return 0;
}


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


int main(){
    int N;
    cin >> N;
    vector<int> a(N);
    vector<bool> seen(N, false);
    rep(i, N){
        cin >> a[i];
        a[i]--;
    }

    int now = 0;
    int cnt = 0;
    while(1){
        if(seen[now]){
            cout << -1 << endl;
            return 0;
        }
        if(now == 1){
            cout << cnt << endl;
            return 0;
        }
        seen[now] = true;
        now = a[now];
        cnt++;
    }

}


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

using namespace std;

int main(){
	vector<int> a(5);
  	int k;
  	for (int i = 0; i < 5; i++){
      cin >> a[i];
    }
  	cin >> k;
  	sort(a.begin(), a.end());
  	if (a[4] - a[0] <= k){
    	cout << "Yay!";
    }
  	else {
      cout << ":(";
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <map>
#include <set>
#include <cstdio>
#include <cmath>
#define rep(i,l,n) for(lint i=l;i<n;i++)
#define rer(i,l,n) for(lint i=l;i<=n;i++)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define pb(a) push_back(a)
#define mk(a,b) make_pair(a,b)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef vector<int> vi;
typedef vector<lint> vli;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

int main(){
	while(1){
		int n;
		cin>>n;
		if(n==0) break;
		vi d(n);
		rep(i,0,n) cin>>d[i];
		int ans=0,i=0;
		bool f=1;
		while(f){
			f=0;
			for(int j=n-1;j>i;j--){
				if(d[j]<d[j-1]){
					swap(d[j],d[j-1]);
					f=1;
					ans++;
				}
			}
			i++;
		}
		o(ans);
	}
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
using namespace std;
int main(){
  int D, G;
  cin >> D >> G;
  vector<int> p(D),c(D);

  for(int i = 0; i < D; ++i){
      cin >> p[i] >> c[i];
  }

  int ans = 1e9;
  for(int tmp = 0; tmp < (1 << D); tmp++){
    bitset<10> x(tmp);
    int s = 0, num = 0, rest_max = -1;
    for(int i = 0; i < D; i++){
      if(x.test(i)){
        s += 100 * (i+1) * p[i] + c[i];
        num += p[i];
      }else{
        rest_max = i;
      }
    }
    if(s < G){
        int s1 = 100 * (rest_max + 1);
        int need = (G - s + s1 - 1) / s1;
        if(need >= p[rest_max]){
            continue;
        }
        num += need;
    }
    ans = min(ans, num);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>

int a[200005],n;

bool check(int x){
	int l=0,r=n*2;bool fl=0,fr=0;
	for (int i=n;i && !l;i--)
		if ((a[i]>=x)==(a[i-1]>=x)) l=i,fl=(a[i]>=x);
	for (int i=n;i<n*2 && r==n*2;i++)
		if ((a[i]>=x)==(a[i+1]>=x)) r=i,fr=(a[i]>=x);
	if (l==0 && r==n*2) return 1;
	if (fl==fr) return fl;
	return n-l<r-n?fl:fr;
}

int main(){
	scanf("%d\n",&n);
	for (int i=1;i<n*2;i++) scanf("%d",&a[i]);
	int l=2,r=n*2-1,ans=1;
	for (;l<=r;){
		int mid=(l+r)>>1;
		if (check(mid)) ans=mid,l=mid+1;
			else r=mid-1;
	}
	printf("%d\n",ans);
}

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

int main() {
  ll a, v, b, w, t;
  cin >> a >> v >> b >> w >> t;
  if (w - v >= 0) {
    cout << "NO" << endl;
  } else {
    if (abs(a - b) <= (v - w) * t) {
      cout << "YES" << endl;
    } else {
      cout << "NO" << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 3636
def examD():
    St = S()
    cur = St.count("g")
    ans = cur - (len(St)+1)//2
    print(ans)

import sys
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examD()

Measured memory_bytes: 3316
n=int(input())
s = {}
for i in range(n):
    ss = input()
    if ss in s:
        s[ss] += 1
    else:
        s[ss] = 1
s2 = sorted(s.items(),key=lambda x:x[1], reverse = True)
ans = []
va = -1
for key,value in s2:
    if va == -1:
        va = value
        ans.append(key)
    else:
        if va == value:
            ans.append(key)

ans.sort()
for x in ans:
    print(x)

Measured memory_bytes: 112984
from bisect import bisect_right

n, m, k = map(int, input().split())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
A = [0]
B = [0]
for i in range(n):
    A.append(A[-1] + a[i])
for j in range(m):
    B.append(B[-1] + b[j])
    
ans = 0
j = m
for i in range(n + 1):
    if A[i] > k:
        break
    while B[j] > k - A[i]:
        j -= 1
    ans = max(ans, i + j)
print(ans)

Measured memory_bytes: 47500
import java.io.*;

public class Main{
	public static void main(String[] args){
		BufferedReader reader=new BufferedReader(new InputStreamReader(System.in));
		try{
			String s;
			while((s=reader.readLine()) !=null){
				String[] t=s.split(" ");
				int sum=0;
				int[] r=new int[2];
				int n=1;
				for(int i=0;i<2;i++){
					r[i]=Integer.parseInt(t[i]);
					sum += r[i];
				}
				for(int j=0;sum/10 !=0;j++){
					sum =sum/10;
					n +=1;
				}
				System.out.println(n);
			}
		}catch(IOException e){
			System.exit(0);
		}
	}
}

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

int main() {
    long long mod = pow(10,9)+7;
    int n;
    cin >> n;
    long long ans=1;
    for (int i=1; i<=n; i++) {
        ans = ans*i %mod;
    }

    cout << ans << endl;
}

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

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

const long long INF = 1LL << 60;

int main(void){
	string s;cin >> s;
	int n = s.length();
	bool ok = true;
	for(int i=0;i<n;i++){
		if(s[i]!=s[n-1-i]) ok = false; 
	}
	int m = (n-1)/2;
	for(int i=0;i<m;i++){
		if(s[i]!=s[m-1-i]) ok = false; 
	}
	int l = (n+3)/2;
	for(int i=0;i<n-l+1;i++){
		if(s[l-1+i]!=s[n-1-i]) ok = false; 
	}
	if(ok) cout << "Yes" << endl;
	else cout << "No" << endl;	
	return 0;
}



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

using namespace std;
using ll = long long;

void pr(int x) { cout << x; }
void pr(ll x) { cout << x; }
void pr(size_t x) { cout << x; }
void pr(const char* s) { cout << s; }
void pr(string& s) { cout << s; }
void pr(bool x) { cout << (x ? "true" : "false"); }

template <typename T1, typename T2>
void pr(const pair<T1, T2>& p) {
    pr("{ "); pr(p.first); pr(", "); pr(p.second); pr(" }");
}

template <typename T> 
void pr(T& v) {
    cout << "{";
    bool f = true; for (const auto& x : v) cout << (!f ? ", " : ""), f = false, pr(x);
    cout << "}";
}

void pd() { cout << "]" << endl; }

template <typename T, typename... U>
void pd(T first, U... rest) {
    pr(first); if (sizeof...(rest)) cout << ", "; pd(rest...);
}

#ifdef TESTING
#define dbg(x...) cout << "[" << #x << "] = [", pd(x)
#else
#define dbg(...)
#endif

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

    int board[3][3];
    bool mark[3][3];
    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
            cin >> board[i][j];
            mark[i][j] = false;
        }
    }

    int n; cin >> n;
    for (int i = 0; i < n; i++) {
        int x; cin >> x;
        for (int u = 0; u < 3; u++) {
            for (int v = 0; v < 3; v++) {
                if (board[u][v] == x) mark[u][v] = true;
            }
        }
    }

    bool ans = false;
    ans |= mark[0][0] && mark[1][1] && mark[2][2];
    ans |= mark[2][0] && mark[1][1] && mark[0][2];
    for (int i = 0; i < 3; i++) {
        ans |= mark[i][0] && mark[i][1] && mark[i][2];
        ans |= mark[0][i] && mark[1][i] && mark[2][i];
    }
    cout << (ans ? "Yes" : "No") << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        char[] s = sc.next().toCharArray();
        int[] wcnt = new int[n];
        int[] ecnt = new int[n];
        for(int i = 0; i < n; i++){
            char chk = s[i];
            if(chk == 'W'){
                wcnt[i]++;
            }else{
                ecnt[i]++;
            }
            if(i != 0){
                wcnt[i] += wcnt[i-1];
                ecnt[i] += ecnt[i-1];
            }
        }
        int ans = Integer.MAX_VALUE;
        for(int i = 0; i < n; i++){
            if(i == 0){
                ans = Math.min(ans,ecnt[n-1]-ecnt[i]);
            }else{
                ans = Math.min(ans,wcnt[i-1] + ecnt[n-1]-ecnt[i]);
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 32228
S=input()
if S=="SUN":
  print(7)
elif S=="MON":
    print(6)
elif S=="TUE":
    print(5)
elif S=="WED":
    print(4)
elif S=="THU":
    print(3)
elif S=="FRI":
    print(2)
elif S=="SAT":
    print(1)
   

Measured memory_bytes: 38256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#define MAX_N 100

using namespace std;
int main(void){
	int tmp,n;
	bool index[5][14];
	char c[5]={0,'S','H','C','D'};
	memset(index,0,sizeof(bool)*70);
	char a;
	cin >> n;
	for (int i=0;i<n;i++){
		cin >>a>>tmp;
		fflush(stdin);
		switch(a){
			case 'S':
				index[1][tmp]=true;
				break;
			case 'H':
				index[2][tmp]=true;
				break;
			case 'C':
				index[3][tmp]=true;
				break;
			case 'D':
				index[4][tmp]=true;
				break;
		}
	}
	for (int i=1;i<=4;i++){
		for (int j=1;j<=13;j++){
				if (!index[i][j]){
				cout << c[i]<<" "<<j<<endl; 
			}
		}
	}

}

Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
int main()
{
    int n;
    cin >> n;
    vector<vector<int>> d(n);
    vector<P> orig(n-1);
    for(int i = 0; i < n-1; i++)
    {
        int a, b;
        cin >> a >> b;
        a--;b--;
        d[a].push_back(b);
        d[b].push_back(a);
        orig[i] = P(a, b);
    }
    int k = 0;
    int start = 0;
    for(int i = 0; i < n; i++)
    {
        if(k < d[i].size())
        {
            k = d[i].size();
            start = i;
        }
    }

    map<P, int> mp;
    vector<bool> was(n);
    bool flag = true;
    function<void(int, int)> dfs = [&](int v, int color)
    {
        int c = 1;
        was[v] = true;
        for(int nx : d[v])
        {
            if(was[nx]) continue;
            if(c == color) c++;
            if(color == 0 && flag)
            {
              c = 1;
              flag = false;
            }
            mp[P(v, nx)] = c;
            mp[P(nx, v)] = c;
            dfs(nx, c);
            c++;
        }
    };
    dfs(start, 0);
    cout << k << endl;
    for(int i = 0; i < n-1; i++)
    {
        P p = orig[i];
        cout << mp[p] << endl;
    }
}


Measured memory_bytes: 20864
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;

using ll = long long;
using ld = long double;
const int INF = 1e9;
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;

int main()
{
  int N;
  cin >> N;
  vector<vector<pair<int, int>>> v;
  for (int i = 0; i < N; ++i)
  {
    vector<pair<int, int>> t;
    int A;
    cin >> A;
    for (int j = 0; j < A; ++j)
    {
      int x, y;
      cin >> x >> y;
      x--;
      t.emplace_back(x, y);
    }
    v.emplace_back(t);
  }

  int ans = 0;
  for (int bit = 0; bit < (1 << N); ++bit)
  {
    bool ok = true;
    for (int i = 0; i < N; ++i)
    {
      for (int j = 0; j < v[i].size(); ++j)
      {
        if (bit & (1 << i))
        {
          int x = v[i][j].first, y = v[i][j].second;
          if ((y && !(bit & (1 << x))) || (!y && (bit & (1 << x))))
            ok = false;
        }
      }
    }
    if (ok)
    {
      ans = max(ans, __builtin_popcount(bit));
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
#define SZ(a) ((int)(a).size())
int main()
{
	int n;
	cin >> n;
	int o = 1, v = 1;
	for (int i = 0; i < n; ++i) {
		int a;
		cin >> a;
		v *= 3;
		o *= (a&1) ? 1 : 2;
	}
	cout << v - o << '\n';
}


Measured memory_bytes: 256
s=[ord(i) for i in input()]
n=[ord(i) for i in input()]
flag=0
flack=0
for i in range(len(s)):
    flack=0
    if n[0]==s[i]:
        flack=1
        for j in range(1,len(n)):
            if i+j>=len(s):
                if n[j]==s[i+j-len(s)]:
                    flack=flack+1
                else:
                    break
            else:
                if n[j]==s[i+j]:
                    flack=flack+1
                else:
                    break
    if flack==len(n):
        flag=1
        break
                
if flag:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 7588
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0;i<static_cast<int>(n);++i)
#define per(i, n) for(int i=static_cast<int>(n)-1;i>=0;--i)
#define eee(a) (cerr<<"[@"<<__LINE__<<"] "<<(#a)<<": "<<(a)<<'\n');
#define ppp(a) (cout<<(a)<<'\n'); 
#define cop(a) for(auto x:(a)){cerr<<(x)<<'\n';}
using ll = long long;
constexpr int dx[4]={1,0,-1,0};
constexpr int dy[4]={0,1,0,-1};
constexpr ll MOD = 1e9+7;
constexpr ll Mod = 998244353;
constexpr int INF = 1e9;
constexpr ll LINF = 1e18;
constexpr double phi = (1+sqrt(5))/2;
constexpr double pi = 3.14159265358979323846264338327950288;
inline ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
inline ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
inline ll inverse(ll n,ll m=MOD){ll a=n,b=m,x=1,y=0;while(b){ll t=a/b;a-=t*b;swap(a,b);x-=t*y;swap(x,y);}return (a%m+m)%m;}
inline void Yes(){puts("Yes");}
inline void No(){puts("No");}
inline void Judge(bool b){b?Yes():No();}
inline void YES(){puts("YES");}
inline void NO(){puts("NO");}
inline void JUDGE(bool b){b?YES():NO();}
inline ll powmod(ll b, ll e, ll m=MOD){ll r=1;while(e>0){if(e&1)r=(r%m)*(b%m)%m;b=(b%m)*(b%m)%m;e>>=1;}return r;}
inline double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));}
inline double d2r(double d){return d*pi/180;}
inline double r2d(double r){return r*180/pi;}
template<class T>inline bool chmax(T &a, const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(b<a){a=b;return 1;}return 0;}
template<typename T>inline int bs(int g,int k,T c){while(abs(k-g)>1){int m=(g+k)/2;(c(m)?k:g)=m;}return k;}
template<typename T1,typename T2>ostream& operator<<(ostream& s,const pair<T1, T2>& p){return s <<"("<<p.first<<", "<<p.second<<")";}
template<typename T> ostream& operator<<(ostream& s,const vector<T>& v){s<<'[';for(size_t i=0;i<v.size();++i){s<<v[i];if(i<v.size()-1)s<<", ";}s<<']';return s;}
template<typename T> istream& operator>>(istream& s,vector<T>& v){for(T& x:v)s>>x;return s;}

int main(){
    cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(15);
    
    double a, b, h, m;
    cin >> a >> b >> h >> m;

    complex H = polar(a, d2r(0.5*m+30.0*h));
    complex M = polar(b, d2r(6.0*m));
    cout << abs(H-M) << '\n';
    
    
    return 0;
}


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

int main()
{
    int x;
    int y = 1;
    scanf("%d",&x);
    if(360 % x == 0){
        printf("%d",360/x);
    }
    else{
        while((x*y)%360 != 0){
            y++;
        }
        printf("%d",y);
    }
    return 0;
}

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

using namespace std;

typedef long long LL;

const int MAXN = 1e5 + 10;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	
	int N, A[MAXN];
	LL sum = 0, ans = 0;
	
	cin >> N;
	
	for (int i = 0; i < N; i++)
		cin >> A[i];
		
	for (int i = 0; i < N; i++)
	{
		if (A[i] == 0)
		{
			ans += sum >> 1;
			sum = 0;
		}//if
		
		sum += A[i];
	}//for i
	
	if (sum > 0)
		ans += sum >> 1;
	
	cout << ans;
	
	return 0;
}//main


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

#define N 500000
#define INFTY 10000000000

int count,A[N];

void merge(int *A,int left,int mid,int right){
  
  int n1,n2,i,j,k;
  
  n1 = mid - left;
  n2 = right - mid;

  long L[n1],R[n2];
  
  for(i=0;i<n1;i++) L[i] = A[left + i];
  for(i=0;i<n2;i++) R[i] = A[mid + i];
  L[n1] = INFTY;
  R[n2] = INFTY;
  i=0;
  j=0;
  for(k=left;k<right;k++){
    count++;
    if(L[i] <= R[j]){
      A[k] = L[i];
      i=i+1;
    }
    else {
      A[k] = R[j];
      j = j+1;
    }
  }
}

void mergesort(int *A,int left,int right){
  int mid;
  if(left+1 < right){
    mid = (left + right)/2;
    mergesort(A,left, mid);
    mergesort(A,mid,right);
    merge(A,left,mid,right);
  }
}



int main(){

  int i,j,n,x,y,mid;
  int A[N];

  scanf("%d",&n);

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

  mergesort(A,0,n);

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



Measured memory_bytes: 7624
n, m = map(int, input().split())
dp = [0] * n
indeg = [0] * n
to = [[] for _ in range(n)]
for _ in range(m):
    x, y = map(int, input().split())
    x -= 1
    y -= 1
    to[x].append(y)
    indeg[y] += 1
avail = list(filter(lambda i: indeg[i] == 0, range(n)))
while avail:
    u = avail.pop()
    for v in to[u]:
        dp[v] = max(dp[v], dp[u] + 1)
        indeg[v] -= 1
        if indeg[v] == 0:
            avail.append(v)
print(max(dp))

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

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n=0,m=0;
  cin>>n;
  m=n%1000;
  if(m==0)
  {
    cout<<m<<endl;
  }
  else 
    cout<<1000-m;
  return 0;
}

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define FIN         ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ii          pair<int,int>
#define F           first
#define S           second
#define pb          push_back
#define all(x)      (x).begin(),(x).end()
#define rall(x)     (x).rbegin(),(x).rend()
#define fore(i,a,b) for(int i = a;i < b; i+= 1)
#define forr(i,a)   for(int i = a; i >= 0; i--)
#define fori(i,m)   for(auto i = m.begin(); i != m.end(); i++) 
#define w(t)        while(t--)
#define sz(s)       int(s.size())
#define cls(a,car)  memset(a,car,sizeof (a))
#define db(x)       cerr << #x << " is " << x << '\n'
#define FI          freopen("input.txt", "r", stdin)
#define FO          freopen("output.txt", "w", stdout)
#define EjecuteTime cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n"
#define angle(x)    double(x * acos(-1) / 180.0)
using namespace std;
typedef long long   ll;
typedef vector<int> vi;
typedef vector<ii>  vii;
const int N = 5e5 + 5;
const ll mod = 1e9 + 7;
const double E = 1e-9;
//int dx[] = {0, -1}, dy[] = {-1, 0};
//int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
//int dx[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy[] = {0, 1, 1, 1, 0, -1, -1, -1};
//int dx[] = {2, 1, -1, -2, -2, -1, 1, 2}, dy[] = {1, 2, 2, 1, -1, -2, -2, -1};
// fflush(stdout)
// cout << flush
// a + b = a ^ b + 2 * (a & b)
int main(){
    FIN;
    ll x, k, d;
    cin >> x >> k >> d;
    x = abs(x);
    ll cur = (x) / d;

    if(k <= cur){
        cout << x - k * d << '\n';
    }else{
        ll now = x - (x / d) * d;
        k -= x / d;
        if(k & 1)
            cout << min(now + d, abs(now - d)) << '\n';
        else
            cout << now << '\n';
    }
    EjecuteTime;
    return 0;
}       


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

using namespace std;

bool mys[100]={0};

int main(){
        string s, t;
        cin>>s>>t;
        for(int i=0;i<(int)s.length();i++){
                if(s[i]=='?'){
                        mys[i]=true;
                }
        }
        int tlen=(int)t.length();
        vector <int> r;
        bool res2=false;
        for(int i=0;i+tlen<=(int)s.length();i++){
                bool flag=true;
                for(int j=0;j<tlen;j++){
                        //cout<<s[i+j]<<":"<<t[j]<<"    ";
                        if(s[i+j]!=t[j]&&s[i+j]!='?'){
                                flag=false;
                                break;
                        }
                }
                if(flag){
                        res2=true;
                        r.push_back(i);
                }
                //cout<<rr<<endl;
        }
        string res[100];
        for(int i=0;i<(int)s.length();i++){
                if(s[i]=='?'){
                        res[0]+='a';
                }
                else{
                        res[0]+=s[i];
                }
        }
        for(int i=1;i<(int)r.size();i++){
                res[i]=res[0];
        }
        string sres="zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz";
        for(int i=0;i<(int)r.size();i++){
                for(int j=r[i];j<r[i]+tlen;j++){
                        res[i][j]=t[j-r[i]];
                }
                sres=min(res[i], sres);
        }
        if(res2)
                cout<<sres<<endl;
        else
                cout<<"UNRESTORABLE"<<endl;
        return 0;
}


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

int main() {
  int A, B, C;
  cin >> A >> B >> C;
  map<int, int> mp;
  mp[A]++;
  mp[B]++;
  mp[C]++;
  if (mp[5] == 2 && mp[7] == 1)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 3636
def min_cost(stones, N):
    space = [0] * N

    for i in range(1, N):
        one = abs(stones[i] - stones[i - 1]) + space[i - 1]
        
        two = 2 ** 31

        if i - 2 >= 0:
            two = abs(stones[i] - stones[i - 2]) + space[i - 2]

        space[i] = min(one, two)

    return space[i]


if __name__ == '__main__':
    N = int(input())
    #stones = list(map(int, input().strip().split()))
    stones = [int(a) for a in input().strip().split()]
    print(min_cost(stones, N))
    
    '''
    stones = [30, 10, 60, 10, 60, 50]
    N = 6
    print(min_cost(stones, N))
    

    stones = [10, 30, 40, 20]
    N = 4
    print(min_cost(stones, N))
    '''

Measured memory_bytes: 13928
//どの道が幾つの街を繋げれるか

#include <bits/stdc++.h>
using namespace std;

    
int main() {
    int N ,M; //,a ,b;
  cin >> N >> M;
  vector<int> a(M);
  vector<int> b(M);
  vector<int> c(N); //= 0;
// vector<int> c(M) = 0; (M)だとだいいから外れる
//  vector<string> だと3+3=33になる
  
  for (int i=0;i<M;i++){
    cin >> a.at(i) >> b.at(i);
  }
  cout << endl;
  
   for (int i=0;i<M;i++){
//    for (int j=0;j<N;j++){
//    for (int j=1;j<N+1;j++){
   for (int j=0;j<N;j++){
//    if ( a.at(i) == j ){
    if ( a.at(i) == j+1 ){
       c.at(j) = c.at(j) + 1;
    }
    else if ( b.at(i) == j+1 ){
        c.at(j) = c.at(j) + 1;
    }
    }
    }
   for (int i=0;i<N;i++){
       cout <<  c.at(i) << endl;
   }
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    Program().solve()
}

class Program {
    fun solve() {
        val sc = MyScanner()
        val a = sc.next().padStart(101,'0')
        val b = sc.next().padStart(101,'0')
        for(i in a.indices){
            if(a[i] != b[i]){
                if(a[i] < b[i]){
                    println("LESS")
                }
                else {
                    println("GREATER")
                }
                return
            }
        }

        println("EQUAL")
    }
}

class MyScanner {
    private var ptr = 0
    private var l = listOf<String>()

    fun next(): String {
        while (l.size <= ptr) {
            l = readLine()!!.split(' ')
            ptr = 0
        }
        return l[ptr++]
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextDouble() = next().toDouble()
    fun nextCharArray() = next().toCharArray()
    fun nextChar() = next()[0]

    fun list(): List<String> {
        ptr = l.size
        return readLine()!!.split(' ')
    }

    fun intList() = list().map { s -> s.toInt() }
    fun longList() = list().map { s -> s.toLong() }
    fun doubleList() = list().map { s -> s.toDouble() }

    fun array() = list().toTypedArray()
    fun intArray() = intList().toIntArray()
    fun longArray() = longList().toLongArray()
    fun doubleArray() = doubleList().toDoubleArray()
}


Measured memory_bytes: 38336
package main

import (
	"bufio"
	"errors"
	"fmt"
	"os"
	"strconv"
)

var n int
var s []int

// 二分探索
func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Scan()
	n, _ = strconv.Atoi(sc.Text())
	s = make([]int, n)
	for i := 0; i < n; i++ {
		sc.Scan()
		v, _ := strconv.Atoi(sc.Text())
		s[i] = v
	}
	sc.Scan()
	q, _ := strconv.Atoi(sc.Text())
	cnt := 0
	for i := 0; i < q; i++ {
		sc.Scan()
		v, _ := strconv.Atoi(sc.Text())
		if _, err := binarySearch(v); err == nil {
			cnt++
			continue
		}
	}
	fmt.Println(cnt)
}

func binarySearch(key int) (int, error) {
	left := 0
	mid := 0
	right := n
	for left < right {
		mid = (left + right) / 2
		if s[mid] == key {
			return mid, nil
		} else if key < s[mid] {
			right = mid
		} else {
			left = mid + 1
		}
	}
	return 0, errors.New("Not found")
}



Measured memory_bytes: 2812
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n; cin >> n;
  vector<long long>a(n+1),b(n);
  for(int i = 0; i < n + 1; i++)
    cin >> a.at(i);
  for(int i = 0; i < n; i++)
    cin >> b.at(i);
  long long sum = 0ll;
  for(int i = 0; i < n; i++){
   // printf("a[%d]:%d a[%d]:%d b[%d]:%d\n",i+1,a.at(i),i+2,a.at(i+1),i+1,b.at(i));
    if(a.at(i) >= b.at(i)) sum += b.at(i);
    else{
      sum += a.at(i);
      b.at(i) -= a.at(i);
      sum += min(a.at(i + 1),b.at(i));
      a.at(i + 1) = max(0ll,a.at(i + 1) - b.at(i));
    }
   // printf("sum = %d\n",sum);
  }
  cout << sum;
  
}

Measured memory_bytes: 4772
import sys
input = sys.stdin.readline

# ユニオンファインド
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

n,m= map(int, input().split())
a= [list(map(int, input().split())) for i in range(m)]
uf = UnionFind(n)
ans1=[n*(n-1)//2]
ans=n*(n-1)//2
for i in range(m-1,0,-1):
    a[i][0]-=1
    a[i][1]-=1
    x=uf.size(a[i][0])
    z=uf.size(a[i][1])
    uf.union(a[i][0],a[i][1])
    y=uf.size(a[i][0])
    if x==y:
        ans1.append(ans)
    else:
        ans-=(y*(y-1)-x*(x-1)-z*(z-1))//2
        ans1.append(ans)


ans1.sort()
for i in ans1:
    print(i)

Measured memory_bytes: 111836
S = input()

a = int(S[:2])
b = int(S[2:])

flag_a = False
flag_b = True

if 1 <= a <= 12 and 1 <= b <= 12:
    print("AMBIGUOUS")
elif 1 <= a <= 12:
    print("MMYY")
elif 1 <= b <= 12:
    print("YYMM")
else:
    print("NA")



Measured memory_bytes: 2940
#include <stdio.h>
#include <stdbool.h>

int main(void){
	int n;
	int a[100005];
	scanf("%d", &n);
	for(int i=0; i<n; i++){
		scanf("%d", &a[i]);
	}

	int ans=0;
	bool two=true;
	while(two){
		two=false;
		for(int i=0; i<n; i++){
			if(a[i] >= 1 && a[i] % 2 == 0){
				ans +=1;
				a[i] /= 2;
				two = true;
			}
		}
	}
	printf("%d",ans);
	return 0;
}


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

vector<long long> enum_divisors(long long n) {
    vector<long long> res;
    for (long long i = 1LL; i * i <= n; i++) {
        if (n % i == 0) {
            res.emplace_back(i);
            if (i * i != n) res.emplace_back(n / i);
        }
    }
    sort(res.begin(), res.end());
    return res;
}

int main() {
    long long N, M; cin >> N >> M;
    long long ans = 1;
    for (long long d: enum_divisors(M)) {
        if (d * N <= M) ans = max(ans, d);
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;
using ll = long long int;
using vec = vector<int>;

#define rep(n) for(int i = 0; i < (n); ++i)
#define Sort(a)    sort(a.begin(), a.end())
#define gSort(a)   sort(a.begin(), a.end(), greater<int>())
const int INF = 2147483647;
const ll  MOD = 1000000007;

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

    int ans = 0;

    while(x >= 500) {
        x -= 500;
        ans += 1000;
    }

    while(x >= 5) {
        x -= 5;
        ans += 5;
    }

    cout << ans;
}

Measured memory_bytes: 256
use std::io::prelude::*;
use std::io::stdin;
use std::str::FromStr;

fn main() {
    let n: usize = read();
    let k: i32 = read();
    let x: Vec<i32> = (0..n).map(|_| read()).collect();

    let mut ans = 0;

    for (i, x_i) in x.iter().enumerate() {
        ans += std::cmp::min(x_i * 2, (k - x_i).abs() * 2);
    }
    println!("{}", ans);
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|b| b.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ull unsigned long long
#define mod 1000000007
#define do double
#define loop(i,n) for(int i=0;i<n;i++)
#define lop(a,b) for(int i=a;i<=b;i++)
#define pb push_back
#define mkp make_pair

typedef vector <int> vi;
typedef map <int,int> mii;
typedef set <int> si;
typedef pair <int,int> pii;
typedef unordered_map <int,int> um;
typedef unordered_set <int> us;
typedef multiset <int> ms;
typedef vector < pair <int,int> > vpii;
int x=0;
// Driver code 
int dfs(int n,vi g[],int i,int dp[])
{
    if(g[i].size()==0)
    {  // vis[i]=true;
        return 0;
    }
    if(dp[i]==0)
    {
        for(int j=0;j<g[i].size();j++)
      {
        x=1+dfs(n,g,g[i][j],dp);
        dp[i]= max(dp[i],x);
      } 
    }  
    return dp[i];
}
int main() 
{ 
    int n,m,mx=0;
    cin>>n>>m;
    vi g[n+1];
    int dp[n+1]={};
    loop(i,m)
    {
        int u,v;
        cin>>u>>v;
        g[u].push_back(v);
    }
    for(int i=1;i<=n;i++)
    {
        dp[i]=dfs(n,g,i,dp);
        mx=max(mx,dp[i]);
    }
    cout<<mx<<"\n";
} 



Measured memory_bytes: 8832
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) FOR(i,0,n)
#define repr(i,n) for(int i=(n)-1;0<=i;--i)
#define each(e,v) for(auto&& e:(v))
#define all(v) begin(v),end(v)
#define DUMP(x) cerr<<#x<<": "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<": "<<(x)<<" (L"<<__LINE__<<")"<<endl
using namespace std;
using vint = vector<int>;
using vdouble = vector<double>;
using vstring = vector<string>;
using ll = long long;
template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }

bool goo(const string& s, int l) {
    string lf = s.substr(0, l/2), rt = s.substr(l/2, l);
    return lf == rt;
}

int main() {
    string s; cin >> s;
    int l = s.size();
    while(l > 0) {
        l -= 2;
        s = s.substr(0, l);
        if(goo(s, l)) break;
    }
    cout << l << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI (3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

/*他のライブラリを入れる場所*/


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,m;
	cin>>n>>m;
	vvl mp(m+1);
	rep(i,n){
		ll a,b;
		cin>>a>>b;
		a=m-a;
		if(a>=m or a<0) continue;
		mp[a].push_back(b);
	}
	priority_queue<ll> q;
	ll ans=0;
	rrep(i,m){
		for(auto&e:mp[i]){
			q.push(e);
		}
		if(q.empty())continue;
		ans+=q.top();
		q.pop();
	}
	puta(ans);
	return 0;
}

Measured memory_bytes: 5632
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main(){
    int a;
    cin >> a;
    cout << a*800-a/15*200 << endl;
    return 0;
}

Measured memory_bytes: 256
from collections import deque

n = int(input())

g = {i: dict() for i in range(n)}

a_list = [0] * (n - 1)
b_list = [0] * (n - 1)
for i in range(n - 1):
    a, b = map(int, input().split())
    a_list[i] = a - 1
    b_list[i] = b - 1
    g[a - 1][b - 1] = -1
    g[b - 1][a - 1] = -1

k = max([len(g[a]) for a in range(n)])

used_color = [-1] * n
used_color[0] = k - 1
# BFS
queue = deque([0])
while len(queue) > 0:
    p = queue.popleft()
    c = used_color[p]
    for q in g[p].keys():
        if used_color[q] != -1:
            continue
        c += 1
        c %= k
        # print(p, q, c)
        g[p][q] = c
        g[q][p] = c
        used_color[q] = c
        queue.append(q)

print(k)
for i in range(n - 1):
    print(g[a_list[i]][b_list[i]] + 1)


Measured memory_bytes: 59328
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll MOD = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
const double EPS = 1e-9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
int main() {
	ll n; cin >> n;
	ll dp[62][4] = {};
	dp[0][0] = 1;
	int chk;
	rep(i, 62) {
		if (n&((ll)1 << i))chk = i+1;
	}
	rep(i, chk) {
		bool f = false;
		if (n&((ll)1 << chk - i - 1))f = true;
		rep(j, 3) {
			if (!dp[i][j])continue;
			rep(k, 3) {
				int nex = j;
				if (j == 0) {
					if ((!f)&&k > 0)continue;
					if (f&&k == 2)continue;
					if (f&&k == 0)nex = 1;
				}
				else if (j == 1) {
					if ((!f) && k == 2)nex = 0;
					else if (f&&k < 2)nex = 2;
					else if ((!f) && k < 1)nex = 2;
				}
				dp[i + 1][nex] = (dp[i + 1][nex] + dp[i][j]) % MOD;
			}
		}
	}
	cout << (dp[chk][0]+dp[chk][1]+dp[chk][2])%MOD << endl;
	return 0;
}

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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define POSSIBLE cout << ((n) ? "POSSIBLE\n" : "IMPOSSIBLE\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)

int64 mypow(int64 n,int64 r){
  if(r == 0)return 1;
  int64 x = mypow(n,r/2);
  x *= x;
  if(r % 2){
    x *= n;
  }
  return x;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int32 n,m;
  cin >> n >> m;
  int64 y = 1900 * m + 100 * (n - m);
  int64 z = mypow(2,m);
  // cout << y << " " << z << endl;
  ANS(y * z);
  return 0;
}

Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>

using namespace std;

#define LL long long
const int maxn = 1e5 + 7;
const int mod = 998244353;

LL qpow(LL a,LL b) {
    LL res = 1;
    while(b) {
        if(b & 1) res = (res * a) % mod;
        a = (a * a) % mod;
        b >>= 1;
    }
    return res;
}

int vis[maxn];

int main() {
    int n;
    while(~scanf("%d",&n)) {
        memset(vis,0,sizeof(vis));
        bool flag = false;
        for(int x , i = 1 ; i <= n ; i++) {
            scanf("%d",&x);
            if(i == 1 && x != 0) {
                flag = true;
            }
            vis[x]++;
        }
        if(flag || vis[0] != 1) printf("0\n");
        else {
            LL ans = 1;
            for(int i = 1 ; i <= n-1 ; i++) {
                ans = ((ans%mod)*(qpow(vis[i-1],vis[i])%mod))%mod;
            }
            cout << ans << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 640
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<queue>
#include<cmath>
#include<vector>
#include<stack>
#include<map>
#include<set>
#define Run(i,l,r) for(int i=l;i<=r;i++)
#define Don(i,l,r) for(int i=l;i>=r;i--)
#define ll long long
#define ld long double
#define inf 0x3f3f3f3f
#define mk make_pair
#define fir first
#define sec second
#define il inline
#define rg register
#define pb push_back
using namespace std;
ll n,a,b; 
int main(){
	cin>>n>>a>>b;
	cout<<(n-a+1)*(n-b+1)<<endl; 
	return 0;
}//by tkys_Austin;


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;
public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner(System.in);
		PrintWriter pw = new PrintWriter(System.out);
		int N = sc.nextInt();
		int[][] list = new int[N][100];
		for(int i = 0;i < N; i++) {
			int a = sc.nextInt();
			for(int j = 1; j <= 100; j++) {
				list[i][j-1] = (j-a)*(j-a);
			}
		}
		int ans = listCheck(list);
		pw.print(ans);
		pw.close();
	}
	
	static int listCheck(int[][] list) {
		int ans = Integer.MAX_VALUE;
		for(int i = 0; i < 100; i++) {
			int check = 0;
			for(int j = 0; j< list.length; j++) {
				check += list[j][i];
			}
			if(ans > check)ans = check;
		}
		return ans;
	}
	
	static class FastScanner {
		private BufferedReader reader = null;
	    private StringTokenizer tokenizer = null;

	    public FastScanner(InputStream in) {
	        reader = new BufferedReader(new InputStreamReader(in));
	        tokenizer = null;
	    }

	    public String next() {
	        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
	            try {
	                tokenizer = new StringTokenizer(reader.readLine());
	            } catch (IOException e) {
	                throw new RuntimeException(e);
	            }
	        }
	        return tokenizer.nextToken();
	    }

	    public String nextLine() {
	        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
	            try {
	                return reader.readLine();
	            } catch (IOException e) {
	                throw new RuntimeException(e);
	            }
	        }

	        return tokenizer.nextToken("\n");
	    }

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

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

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

	    public int[] nextIntArray(int n) {
	        int[] a = new int[n];
	        for (int i = 0; i < n; i++)
	            a[i] = nextInt();
	        return a;
	    }

	    public long[] nextLongArray(int n) {
	        long[] a = new long[n];
	        for (int i = 0; i < n; i++)
	            a[i] = nextLong();
	        return a;
	    }
	}
}

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

using namespace std;

int main(void)
{
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);

	string s;
	cin >> s;
	char prev = s[0];
	for (int i = 1; i < (int) s.length(); i++) {
		if (s[i] == prev) {
			cout << i << ' ' << i + 1 << '\n';
			return 0;
		}
		prev = s[i];
	}
	for (int i = 0; i < (int) s.length() - 2; i++) {
		if (s[i] == s[i + 2]) {
			cout << i + 1 << ' ' << i + 3 << '\n';
			return 0;
		}
	}
	cout << "-1 -1\n";

	return 0;
}



Measured memory_bytes: 512
#include<bits/stdc++.h>
using  namespace  std;
int main()
{
    int k;
    string s,c;
    cin>>k;
    cin>>s;
    if(k>=s.size())
        cout<<s<<endl;
    else
    {
        for(int i=0; i<k; i++)
            c+=s[i];
        cout<<c;
        cout<<"..."<<endl;
    }
    return 0;
}

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

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

int main() {
    long A, B;
    cin>>A>>B; 
    cout << (A*B/gcd(A, B)) << endl;
}

Measured memory_bytes: 256