akhauriyash/Code-Regression huggingface dataset:
//ΔARC099D
#include<iostream>
#include<cstdio>
#include<fstream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<bitset>
#include<cmath>
#include<cstring>
#include<cstdlib>
using namespace std;
typedef long long LL;
typedef double DB;
const LL inf = 1e17;
int S(LL x){
	if(!x)
		return 0;
	return x%10+S(x/10);
}
LL a[111111];
DB p[111111];
int main()
{
	int n=0,i,j,f,k;
	LL x;
	cin>>k;
	for(i=1;i<=200;i=i+1){
		for(x=i;x<=inf;x=x*10)
			if(x-1)
				a[n++]=x-1;
	}
	sort(a,a+n);
	n=unique(a,a+n)-a;
	for(i=0;i<n;i=i+1)
		p[i]=(DB)a[i]/S(a[i]);
	for(i=0;i<n;i=i+1){
		f=1;
		for(j=i;j<n;j=j+1)
			if(p[i]>p[j])
				f=0;
		if(f&&k)
			k--,cout<<a[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x)          (x).begin(), (x).end()
#define rep(i, n)       for (i64 i = 0, i##_limit = (n); i < i##_limit; ++i)
#define reps(i, s, t)   for (i64 i = (s), i##_limit = (t); i <= i##_limit; ++i)
#define repr(i, s, t)   for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#define var(Type, ...)  Type __VA_ARGS__; input(__VA_ARGS__)
#ifndef DBG
#define trace(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U> inline bool chmax(T &a, const U &b) { return b > a && (a = b, true); }
template <class T, class U> inline bool chmin(T &a, const U &b) { return b < a && (a = b, true); }
inline i64  sigma(i64 n)            { return (n * (n + 1) >> 1); }
inline i64  updiv(i64 a, i64 b)     { return (a + b - 1) / b; }
inline i64  sqr(i64 n)              { return n * n; }
inline string to_string(char c)     { return string(1, c); }
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> make_v(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}
template <class T, class... Args>
inline auto make_v(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(make_v<T>(initValue, args...))>(sz, make_v<T>(initValue, args...));
}

inline void input() {}
template <class Head, class... Tail>
inline void input(Head &head, Tail&... tail) { cin >> head; input(tail...); }

inline void print() { cout << "\n"; }
template <class Head, class... Tail>
inline void print(Head &&head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream& operator<< (ostream &out, const vector<T> &vec) {
    static constexpr const char *delim[] = { " ", "" };
    for (const auto &e : vec) out << e << delim[&e == &vec.back()];
    return out;
}

template <typename Func>
struct FixPoint : Func {
    inline constexpr FixPoint(Func &&f) noexcept : Func(forward<Func>(f)) {}

    template <typename... Args>
    inline decltype(auto) operator()(Args &&... args) const {
        return Func::operator()(*this, forward<Args>(args)...);
    }
};

template< typename Func >
inline decltype(auto) makeFixPoint(Func &&f) {
    return FixPoint< Func >{forward< Func >(f)};
}
// }}} End Header

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

    var(int, N);
    set<int> S;

    rep(i, N) {
        var(int, a);
        S.insert(a);
    }

    print(S.size());

    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python
# -*- coding: utf-8 -*-

def main():
    N = int(input())
    h = [int(i) for i in input().split()]
    dp = [0] * N
    for i in range(1, N):
        if i < 2:
            dp[i] = abs(h[i-1] - h[i])
        else:
            dp[i] = min(dp[i-1] + abs(h[i-1] - h[i]), dp[i-2] + abs(h[i-2] - h[i]))
    print(dp[-1])

if __name__ == "__main__":
    main()

Measured memory_bytes: 13924
//#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a<=x&&x<b)
#define MP make_pair
#define PB push_back
#define INF (1LL<<30)
#define LLINF (1LL<<60)
#define PI 3.14159265359
#define EPS 1e-12
//#define int ll

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }

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

signed main(void)
{
  int a, b;
  cin >> a >> b;
  if(a%3 == 0 || b%3==0 || (a+b)%3==0) cout << "Possible" << endl;
  else cout << "Impossible" << endl;

  return 0;
}


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

int main () {
  string S ;
  cin >> S ;
  int a = 0 , b = 0 , ans = 0 ;
  for(int i = 0 ; i < S.size() ; i++ ){
    if(S[i]=='0') {
      a++ ;
    } else {
      b++ ;
    }
    if( a > 0 && b > 0 ) {
      ans++ ;
      a--;
      b--;
    }
  }
  cout << ans * 2 << endl ;
}

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

using namespace std;

//typedef pair<int, int> P;
#define int long long
#define ll long long
#define mod 1000000007
#define INF (1LL<<60)

template<class Abel> struct UnionFind {
	vector<int> par;
	vector<int> rank;
	vector<Abel> diff_weight;

	UnionFind(int n = 1, Abel SUM_UNITY = 0) {
		init(n, SUM_UNITY);
	}

	void init(int n = 1, Abel SUM_UNITY = 0) {
		par.resize(n); rank.resize(n); diff_weight.resize(n);
		for (int i = 0; i < n; ++i) par[i] = i, rank[i] = 0, diff_weight[i] = SUM_UNITY;
	}

	int root(int x) {
		if (par[x] == x) {
			return x;
		}
		else {
			int r = root(par[x]);
			diff_weight[x] += diff_weight[par[x]];
			return par[x] = r;
		}
	}

	Abel weight(int x) {
		root(x);
		return diff_weight[x];
	}

	bool issame(int x, int y) {
		return root(x) == root(y);
	}

	bool merge(int x, int y, Abel w) {
		w += weight(x); w -= weight(y);
		x = root(x); y = root(y);
		if (x == y) return false;
		if (rank[x] < rank[y]) swap(x, y), w = -w;
		if (rank[x] == rank[y]) ++rank[x];
		par[y] = x;
		diff_weight[y] = w;
		return true;
	}

	Abel diff(int x, int y) {
		return weight(y) - weight(x);
	}
};

signed main(){

	int N, M;
	cin >> N >> M;

	UnionFind<int> u(N);

	for (int i = 0; i < M; i++){
		int l, r, d;
		cin >> l >> r >> d;
		l--; r--;
		if (!u.issame(l,r))
			u.merge(l, r, d);
		else
			if (u.diff(l, r) != d){
				cout << "No" << endl;
				return 0;
			}
	}

	cout << "Yes" << endl;
	
	return 0;
}


Measured memory_bytes: 2688
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
k=int(input())

l = [a, b, c, d, e]
cnt = 0

for i in range(len(l)):
    for j in range(len(l)-i):
        if(l[i]-l[j] > k):
            cnt += 1
            break
if(cnt==0):
    print('Yay!')
else:
    print(':(')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

const string cand[16] = {"KIHBR", "KIHBRA", "KIHBAR", "KIHBARA", "KIHABR", "KIHABRA", "KIHABAR", "KIHABARA",
				"AKIHBR", "AKIHBRA", "AKIHBAR", "AKIHBARA", "AKIHABR", "AKIHABRA", "AKIHABAR", "AKIHABARA"};

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

	string S; cin >> S;
	bool ok = false;
	rep (i, 16){
		ok |= (S == cand[i]);
	} // end rep

	cout << (ok ? "YES" : "NO") << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <algorithm>
#include <limits>
#include <cmath>

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
#define rep(i, a, b) for(int i = (a); i < (b); ++i )
#define rrep(i, a, b) for(int i = (a); i > (b); --i )
#define REP(i, a, b) for(int i = (a); i <= (b); ++i )
#define RREP(i, a, b) for(int i = (a); i >= (b); --i )

ull ptn[10];
ull A, B, C, X, Y;
int main() {
    cin >> A >> B >> C >> X >> Y;

    // C highest
    if ((A <= C) && (B <= C)) {
        cout << A * X + B * Y << endl;
        return 0;
    }

    ull sum = 0;
    ull m = A < B ? A : B;
    ull mn = 0;
    ull ln = 0;
    if (m == A) {
        mn = X;
        ln = Y;
    } else {
        mn = Y;
        ln = X;
    }
    ull l = A >= B ? A : B;

    // C lowest
    if ((C <= A) && (C <= B)) {
        if (ln >= mn) {
            sum += C * mn * 2;
            ull ac = (ln - mn) * l;
            ull bc = (ln - mn) * 2 * C;
            sum += ac < bc ? ac : bc;
            cout << sum << endl;
            return 0;
        }else{
            sum += C * ln * 2;
            ull ac = (mn - ln) * m;
            ull bc = (mn - ln) * 2 * C;
            sum += ac < bc ? ac : bc;
            cout << sum << endl;
            return 0;
        }
    }
    // C middle

    if ((m + l) <= (C * 2)) {
        ull ac = m * mn + l * ln;
        ull bc = m * mn + 2 * C * ln;
        cout << (ac < bc? ac: bc) << endl;
        return 0;
    }
    if (ln >= mn) {
        sum += C * mn * 2;
        ull ac = (ln - mn) * l;
        ull bc = (ln - mn) * 2 * C;
        sum += ac < bc ? ac : bc;
        cout << sum << endl;
        return 0;
    }else{
        sum += C * ln * 2;
        ull ac = (mn - ln) * m;
        ull bc = (mn - ln) * 2 * C;
        sum += ac < bc ? ac : bc;
        cout << sum << endl;
        return 0;
    }
    cout << "a" << endl;
    cout << "b" << endl;
    cout << "c" << endl;
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  string s;
  cin >> s;
  int ans = 700;
  rep(i, 3) if (s[i] == 'o') ans += 100;

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


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int N = 0;
    scanf("%d", &N);
    

    int i;
    int H[N];
   for(i=0;i<N;i++){   
      scanf("%d", &H[i]);
   }

   int max=0;
   max = H[0];
   int ans= 0;
   int count=0;
   for(i=0;i<N;i++){
       if(max <= H[i]){
           count++;
           max = H[i];
       }
   }
    printf("%d",count);
       return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x)  x.begin(),x.end()
#define vi vector<int>
#define vll vector<ll>
#define print(x) for(auto it=x.begin();it!=x.end();it++) cout<<*it<<' '; cout<<'\n';
#define debug(a,b,c) cout << a << " " << b << " " << c << endl;
#define in(x,n) for(int e=0;e<n;e++){int y;cin>>y;x.pb(y);}
#define inl(x,n) for(int e=0;e<n;e++){ll y;cin>>y;x.pb(y);}
#define lower(sl)  transform(sl.begin(), sl.end(), sl.begin(), ::tolower); 

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
      int n,q;
      cin >> n;
      vll a;
      unordered_map<ll,ll> m;
      inl(a,n);
      vll b,c;
      cin >> q;
      for(ll i=0;i<q;i++){
            ll x,y;cin >>x>>y;
            b.pb(x);c.pb(y);
      }

      ll sum =0;
      for(ll i=0;i<n;i++){
            m[a[i]]++;
            sum += a[i];
      }

      for(ll i=0;i<q;i++){
            ll cx =0;
            if(m[b[i]]){
                  cx = m[b[i]];
                  m[b[i]] = 0;
            } else {
                  cout << sum << endl;
                  continue;
            }
            m[c[i]]+=cx;
            sum -= b[i]*cx;
            sum += c[i]*cx;
            cout << sum << endl;
      }


      
}


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

#define int long long

int n,m, p = 0, im = 0;

int32_t main()
{	
	cin >> n >> m;
	p = n*(n-1)/2;
	im = m*(m-1)/2;
	
	cout << p + im << '\n';
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T> using vt = vector<T>;
template<class T> using vvt = vector<vt<T>>;
template<class T> using ttt = tuple<T,T>;
using tii = tuple<int,int>;
using vi = vector<int>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define mt make_tuple
#define ALL(a) (a).begin(),(a).end()
#define FST first
#define SEC second
#define DEB cerr<<"!"<<endl
#define SHOW(a,b) cerr<<(a)<<" "<<(b)<<endl
#define DIV int(1e9+7)
const int INF = (INT_MAX/2);
const ll LLINF = (LLONG_MAX/2);
const double eps = 1e-8;
//const double PI = M_PI;  
inline ll pow(ll x,ll n,ll m){ll r=1;while(n>0){if((n&1)==1)r=r*x%m;x=x*x%m;n>>=1;}return r%m;}
inline ll lcm(ll d1, ll d2){return d1 / __gcd(d1, d2) * d2;}

/* Coding space */
int a[100000] ={};
int main(){
  int h,w,d; cin >> h >> w >> d;
  map<int,tii> m;
  map<int,map<int,int>>ans;
  rep(i,h)rep(j,w){
    int in; cin >> in;
    m[in] = tii{i,j};
  }
  
  for(int i = 1; i <= d; i++){
  int s = i;
  while(s+d <= h*w){
    int sx,sy; tie(sx,sy) = m[s];
    int nx,ny; tie(nx,ny) = m[s+d];
    s += d;
    a[s] = abs(sx-nx) + abs(sy-ny);
    a[s] += a[s-d];
  }
  }
  
  
  
  int q; cin >> q;
  rep(i,q){
    int s,g; cin >> s >> g;
    cout << a[g] - a[s] << endl;
  }
}

Measured memory_bytes: 7040
def solve():
    N = int(input())
    arr = list(map(int, input().split()))
    arr.append(0)

    i = 0
    magic_cnt = 0
    while i < N:
        adj_cnt = 1
        while i < N and arr[i] == arr[i + 1]:
            i += 1
            adj_cnt += 1
        magic_cnt += int(adj_cnt / 2)
        i += 1
    print(magic_cnt)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 3060
#include <stdio.h>
#include <math.h>

#define N 10000

int main()
{
  int i, num, ans=0, count, sign=0;
  int array[N];

  scanf("%d", &num);

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

  for( i=0; i<num; i++){
    if( array[i] == 2 ){
      ans++;
      continue;
    }
    
    if( array[i] < 2 || array[i] % 2 == 0 ) continue;
    
    count = 3;

    while( count <= sqrt(array[i]) ){
      if( array[i] % count == 0 ){
	sign = 1;
	break;
      }
      
      count += 2;
    }
    
    if( sign == 0 )ans++;
    sign = 0;
  }
  
    printf("%d\n", ans);

    return 0;
}

Measured memory_bytes: 632
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef vector< vector<int> > VVI;
typedef vector< vector<ll> > VVL;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
#define ub upper_bound
#define lb lower_bound

int main(){
  int N,M;
  cin>>N>>M;
  VI X(M),Y(M);
  rep(i,M) cin>>X[i]>>Y[i];
  VI Z(N),F(N);
  F[0]=1;
  rep(i,N) Z[i]=1;
  rep(i,M){
    if(F[X[i]-1]) F[Y[i]-1]=1;
    Z[X[i]-1]--;
    Z[Y[i]-1]++;
    if(Z[X[i]-1]==0) F[X[i]-1]=0;
  }
  int ans=0;
  rep(i,N) ans+=F[i];
  cout<<ans<<endl;
}

Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {
	
	public static double compute(long l) {
		long sum = 0;
		long t = l;
		while (t > 0) {
			sum += t % 10;
			t /= 10;
		}
		return (double)l / sum;
	}
	
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int k = s.nextInt();
		
		long current = 1;
		for (int i = 0; i < k; i++) {
			double min = Double.MAX_VALUE;
			long next = -1; 
			String currentString = current + "";
			for (int j = 0; j < currentString.length() + 1; j++) {
				String ender = "";
				for (int m = 0; m < j; m++) {
					ender += "9";
				}
				String temp = currentString.substring(0, currentString.length() - j) + ender;
				long tempVal = new Long(temp);
				double ans = compute(tempVal);
				if (ans < min) {
					min = ans;
					next = tempVal;
				}
			}
			System.out.println(next);
			current = next + 1;
		}
	}

}


Measured memory_bytes: 28756
#include <cstdio>

using namespace std;

int main(){
	int a,b;
	int sum=0;
	int i;
	while(scanf("%d %d",&a,&b)!=EOF){
		sum=a+b;
		for(i=0;sum!=0;i++){
			sum/=10;
		}
		printf("%d\n",i);
		sum=0;
	}
	return 0;
}

Measured memory_bytes: 0
row = []
for i in range(3):
	row.append(list(map(int, input().split())))

a1 = 0
b1 = row[0][0]
b2 = row[1][0]
b3 = row[2][0]

a2 = row[0][1] - b1
a3 = row[0][2] - b1

if a2 + b2 == row[1][1] and a3 + b2 == row[1][2] and a2 + b3 == row[2][1] and a3 + b3 == row[2][2] :
	print("Yes")
else:
	print("No")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lld long double
#define pii pair<int,int>
#define MOD 1000000007
void solve(){
    string s; cin>>s;
    ll len = s.length();
    if(s[len-1]=='s'){
        s+="es";
    }
    else s+="s";
    cout<<s<<endl;
}
int main(){
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t = 1; 
    // cin>>t;
    while(t-->0){
        solve();
    }
    return 0;
}


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

int n;
ll a[312345];
ll l[312345];
ll r[312345];
int main() {
  ios::sync_with_stdio(false), cin.tie(0);
  cin >> n;
  for(int i = 0; i < 3 * n; i++) cin >> a[i];
  ll ans = -1e18;
  {
    priority_queue<int, vector<int>, greater<int>> pq;

    ll now = 0;
    for(int i = 0; i < 3 * n; i++) {
      if(pq.size() < n) {
        pq.emplace(a[i]);
        now += a[i];
        l[i] = now;
        continue;
      }
      ll t = pq.top(); pq.pop();
      now -= t;
      now += max(t, a[i]);
      pq.emplace(max(t, a[i]));
      l[i] = now;
    }
  }
  {
    priority_queue<int> pq;

    ll now = 0;
    for(int i = 3 * n - 1; i >= 0; i--) {
      if(pq.size() < n) {
        pq.emplace(a[i]);
        now += a[i];
        r[i] = now;
        continue;
      }
      ll t = pq.top(); pq.pop();
      now -= t;
      now += min(t, a[i]);
      pq.emplace(min(t, a[i]));
      r[i] = now;
    }
  }

  for(int i = n-1; i < n + n; i++) {
    ans = max(ans, l[i] - r[i + 1]);
  }

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


Measured memory_bytes: 8432
import java.util.*;

public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    String  S = sc.next();
    String  T = sc.next();    

    char[] s = S.toCharArray();
    char[] t = T.toCharArray();

    int cou = 0;
    for(int i=0; i<3; i++){
	if(s[i]==t[i]){
	    cou++;
	}
    }
		System.out.println(cou);
	}
}

Measured memory_bytes: 22868
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

def primes_for(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, n + 1):
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]


def divisor(n): #nの約数を全て求める
    i = 1
    table = []
    while i * i <= n:
        if n%i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = list(set(table))
    return table

def factorial(n):
    res = 1
    for i in range(1, N+1):
        res *= i
    return res

N = INT()
f = factorial(N)
divisor = 1
A = [0] * (N + 1)

prime_list = primes_for(N)
tmp = f
for p in prime_list:
    cnt = 0
    if tmp % p == 0:
        while tmp % p == 0: 
            tmp = tmp // p
            A[p] += 1

for a in A:
    divisor *= (a + 1)
print(divisor % mod)


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define SP << " " 
#define LLi long long int

using namespace std;

int imax=2147483647;
long long int llimax=9223372036854775807;

//int型vectorを出力
void PV(vector<int> pvv) {
	rep(i, pvv.size()) cout << pvv[i] SP;
	cout << endl;
}

//LLi型vectorを出力
void PVL(vector<LLi> pvv) {
	rep(i, pvv.size()) cout << pvv[i] SP;
	cout << endl;
}

int main(){

	int ans=0;
	string s;

	cin>> s;

	rep(i, s.size()) ans+=(int)(s[i]-'0');


	if(ans%9==0) cout<< "Yes" << endl;
	else cout<< "No" << endl;
 
	return 0;
}

Measured memory_bytes: 3700
#include<bits/stdc++.h>
#define inf 1<<29
#define linf (1e16)
#define eps (1e-8)
#define Eps (1e-12)
#define mod 1000000007
#define pi acos(-1.0)
#define phi (1.0+sqrt(5.0))/2.0
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define pd(a) printf("%.10f\n",(double)(a))
#define pld(a) printf("%.10Lf\n",(ld)(a))
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(a)-1;(b)<=i;i--)
#define Unique(v) v.erase(unique(all(v)),v.end())
#define equals(a,b) (fabs((a)-(b))<eps)
using namespace std;
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<int,double> pid;
typedef pair<double,int> pdi;
typedef pair<double,double> pdd;
typedef vector<int> vi;
typedef vector<pii> vpi;

class Point{
public:
  double x,y;
  Point(double x=0,double y=0):x(x),y(y){}

  Point operator+(Point p){ return Point(x+p.x,y+p.y);}
  Point operator-(Point p){ return Point(x-p.x,y-p.y);}
  Point operator*(double k){ return Point(x*k,y*k);}
  Point operator/(double k){ return Point(x/k,y/k);}
  bool operator<(Point p)const{ 
    return equals(x,p.x) ? y-p.y<-eps : x-p.x<-eps; }
  bool operator==(Point p)const{ 
    return fabs(x-p.x)<eps && fabs(y-p.y)<eps;}

  double abs(){ return sqrt(norm());}
  double norm(){ return (x*x+y*y);}
};
typedef Point Vector;
typedef vector<Point> Polygon;

double norm(Vector a){ return (a.x*a.x+a.y*a.y);}
double abs(Vector a){ return sqrt(norm(a));}
double dot(Vector a,Vector b){ return (a.x*b.x+a.y*b.y);}
double cross(Vector a,Vector b){ return (a.x*b.y-a.y*b.x);}

class Circle{
public:
  Point c;
  double r;
  Circle(Point c=Point(),double r=0.0):c(c),r(r){}
};

int intersect(Circle a,Circle b){
  double d=abs(a.c-b.c);
  if(a.r<b.r)swap(a,b);
  if(a.r+b.r+eps<=d)return 4;
  if(a.r+b.r-eps<=d)return 3;
  if(a.r-b.r+eps<=d)return 2;
  if(a.r-b.r-eps<=d)return 1;
  return 0;
}

int main()
{
  Circle a,b;
  cin>>a.c.x>>a.c.y>>a.r;
  cin>>b.c.x>>b.c.y>>b.r;
  cout<<intersect(a,b)<<endl;
  return 0;
}


Measured memory_bytes: 3204
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int []P = new int[M];
		int []Y = new int[M];
		for(int i = 0; i < M; i++) {
			P[i] = sc.nextInt();
			Y[i] = sc.nextInt();
		}
		sc.close();

		Data []d = new Data[M];
		for(int i = 0; i < M; i++) {
			d[i] = new Data(i + 1, Y[i], P[i]);
		}
		Map<Integer, List<Data>> map = new HashMap<Integer, List<Data>>();
		for(int i = 0; i < M; i++) {
			if(map.containsKey(d[i].p)) {
				map.get(d[i].p).add(d[i]);
			}else {
				List<Data> list = new ArrayList<Data>();
				list.add(d[i]);
				map.put(d[i].p, list);
			}
		}
		for(int key : map.keySet()) {
			List<Data> list = map.get(key);
			Collections.sort(list, new MyComparator());
			int cnt = 1;
			for(Data t : list) {
				String s1 = String.format("%06d", t.p);
				String s2 = String.format("%06d", cnt);
				cnt++;
				t.n = s1 + s2;
			}
		}
		for(Data t : d) {
			System.out.println(t.n);
		}
	}
	static class Data{
		int id, y, p;
		String n;
		public Data(int id, int y, int p) {
			this.id = id;
			this.y = y;
			this.p = p;
		}
	}
	 static class MyComparator implements Comparator<Data>{
		 @Override
        public int compare(Data d1, Data d2) {
			 if(d1.y > d2.y) {
				 return 1;
			 }else if(d1.y < d2.y) {
				 return -1;
			 }else {
				 return 0;
			 }
		 }
	 }

}

Measured memory_bytes: 179616
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
int main()
{
    int n,k;
    cin >> n >> k;
    const int size = 200000;
    int a[size] = {};
    set<int> s;
    for(int i = 0;i < n;i++)
    {
        int A;
        cin >> A;
        a[A - 1]++;
        s.insert(A);
    }
    sort(a,a + size);
    int ans = 0;
    int l = s.size() - k;
    for(int i = 0;i < size && l > 0;i++)
    {
        if(a[i] > 0)
        {
            ans += a[i];
            l--;
        }
    }
    cout << ans << "\n";

    return 0;
}

Measured memory_bytes: 10368
s=input()
first=int(s[0:2])
last=int(s[2:4])

if last>=1 and last<=12 and first>=1 and first<=12:
    print("AMBIGUOUS")

elif last>=1 and last<=12 :
    print("YYMM")
elif first>=1 and first<=12:
    print("MMYY")
else:
    print("NA")


Measured memory_bytes: 38256
from collections import deque
n,m=map(int,input().split())
edge=[]
ans=[-1]*n
for i in range(n):
    edge.append([])
for i in range(m):
    x,y=map(int,input().split())
    edge[x-1].append(y-1)
    edge[y-1].append(x-1)
q=deque([0])
while q:
    x=q.popleft()
    for i in range(len(edge[x])):
        if ans[edge[x][i]]==-1:
            ans[edge[x][i]]=x+1
            q.append(edge[x][i])
print('Yes')
for i in range(len(ans)-1):
    print(ans[i+1])

Measured memory_bytes: 37128
//ワーシャルフロイド
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
#define INF 1000001

int mincost[100];
struct Edge{
	int from,to;
	int cost;
	Edge(int a,int b,int c):from(a),to(b),cost(c){}
};

int main(){
	int n,m,p,q,r,k;
	int a,b,c,d;
	vector<Edge> cost[2];
	while(cin>>n>>m,n|m){
		cost[0].clear();
		cost[1].clear();
		for(int i=0;i<n;i++){
			cin>>a>>b>>c>>d;
			a--;b--;
			cost[0].push_back(Edge(a,b,c));
			cost[0].push_back(Edge(b,a,c));
			cost[1].push_back(Edge(a,b,d));
			cost[1].push_back(Edge(b,a,d));
		}
		cin>>k;
		while(k--){
			bool updata;
			fill_n((int*)mincost,sizeof(mincost)/sizeof(int),INF);
			cin>>p>>q>>r;
			p--;q--;
			mincost[p]=0;
			do{
				updata=false;
				for(int i=0;i<2*n;i++){
					Edge &e=cost[r][i];
					if(mincost[e.from]+e.cost < mincost[e.to]){
						mincost[e.to] = mincost[e.from]+e.cost;
						updata=true;
					}
				}
			}while(updata);
			cout<<mincost[q]<<endl;
		}
	}
}

Measured memory_bytes: 1128
#include<bits/stdc++.h>
#include <boost/rational.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;
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; }


using namespace std;

int main(){
    int N;
    cin >> N;
    int a[N];
    rep(i, N){
        cin >> a[i];
    }
    bool flag = true;
    rep(i, N){
        if (a[i] % 2 == 0) {
            if (a[i] % 6 != 0 && a[i] % 10 != 0) {
                flag = false;
            }
        }
    }
    if (flag) {
        cout << "APPROVED" << endl;
    } else {
        cout << "DENIED" << endl;
    }

};

Measured memory_bytes: 256
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
constexpr ll INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
constexpr ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
ll n, cnt, ans, a[ohara], b, c, d, tmp, m, h, w, x, y, sum, k, q;
ll mem[600][600];
bool out[600][600];

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

  cin >> n;
  rep(i, n * n) cin >> a[i], a[i]--;
  rep(i, n) {
    rep(j, n) { mem[i][j] = min({i, j, n - i - 1, n - j - 1}); }
  }
  rep(i, n * n) {
    ll nowy, nowx, mi = LINF;
    nowy = a[i] / n;
    nowx = a[i] % n;
    ans += mem[nowy][nowx];
    out[nowy][nowx] = true;

    queue<P> qu;
    qu.push({nowy, nowx});
    while (!qu.empty()) {
      auto p = qu.front();
      qu.pop();
      rep(z, 4) {
        int nx = p.se + dx[z], ny = p.fi + dy[z];
        int cost = 0;
        if (nx < 0 || ny < 0 || nx >= n || ny >= n) continue;
        if (!out[p.fi][p.se]) cost = 1;
        if (mem[p.fi][p.se] + cost >= mem[ny][nx]) continue;
        mem[ny][nx] = mem[p.fi][p.se] + cost;
        qu.push({ny, nx});
      }
    }
  }
  Cout(ans);
  return 0;
}

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

int main()
{
	int i, j, k, n, x, count;
	while (true)
	{
		count = 0;
		cin >> n >> x;
		if (n == 0 && x == 0) break;
		for (i = 1;i <= n;i++) {
			for (j = i;j <= n;j++) {
				for (k = j;k <= n;k++) {
					//cout << i << " " << j << " " << k << " " << i + j + k;
					if (i+j+k==x && i!=j && i!=k && j !=k) {
						count += 1;
						//cout << "Pluse";
					}
					//cout << endl;
				}
			}
		}
		cout << count << endl;
	}
}


Measured memory_bytes: 3072
#include <iostream>
#include <cmath>
#include <vector>
using namespace std;

int mod = 998244353;

int main()
{
	int n,k;
	cin >> n >> k;
	long a[n];
	for(int i=0;i<n;i++)
	{
		cin >> a[i];
	}

	long dp[n];
	for(int i=0;i<n;i++)
	{
	    dp[i] = 1e9;
	}
	dp[0] = 0;
	for(int i=0;i<n;i++)
	{
		
	    for(int j=i+1;j<=i+k;j++){
	        if(j<n){
	            dp[j] = min(dp[j],dp[i]+abs(a[j]-a[i]));    
	        }
	         
	    }
	}
	
	
 	cout  << dp[n-1] << endl;	
}

Measured memory_bytes: 1792
// #pragma GCC optimize("no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
// #pragma vector temporal
// #pragma simd
// #pragma GCC diagnostic ignored "-W"

#include<cassert>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<ctime>
#include<algorithm>
#include<iostream>
#include<iomanip>
#include<sstream>
#include<deque>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<vector>
#include<utility>
#include<functional>
#include<complex>
#include<climits>

// #include<ext/pb_ds/assoc_container.hpp>
// #include<ext/pb_ds/tree_policy.hpp>

using namespace std;
// using namespace __gnu_pbds;

#define ll long long
#define ld long double
#define X first
#define Y second
#define pb push_back
#define eb emplace_back
#define pii pair<int,int>
#define vint vector<int>
#define SS stringstream
#define PQ priority_queue
#define MS(x,v) memset((x),(v),sizeof(x))
#define RZUNI(x) sort(x.begin(),x.end()), x.resize(unique(x.begin(),x.end())-x.begin())
#define FLH fflush(stdout)
#define CPPinput ios_base::sync_with_stdio(0); cin.tie(0)
#define FIN(fname) freopen(fname,"r",stdin)
#define FOUT(fname) freopen(fname,"w",stdout)

#define tm Ovuvuevuevue
#define y1 Enyetuenwuevue
#define left Ugbemugbem
#define ws Osas
#define dec tetteterette
#define exp expexpexpexp
#define expl explexplexpl

#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl

#ifdef WEAK
#include"/home/edison/Coding/cpp/template/debug.cpp"
#define DEB(...) printf(__VA_ARGS__),fflush(stdout)
#define WHR() printf("%s: Line %d",__PRETTY_FUNCTION__,__LINE__),fflush(stdout)
#define LOG(...) printf("%s: Line %d ",__PRETTY_FUNCTION__,__LINE__),printf(__VA_ARGS__),fflush(stdout)
#define DEBUG 1
#define exit(x) cout<<"exit code "<<x<<endl, exit(0)
#else
#define PDE(...) ;
#define DEB(...) ;
#define WHR() ;
#define LOG(...) ;
#define DEBUG 0
#endif

#define lowbit(x) ((x)&(-(x)))

#if __cplusplus >= 201103L
#include<unordered_map>
#include<unordered_set>
#include<tuple>
#endif

void JIZZ(string output=""){cout<<output; exit(0);}

const ld PI=3.14159265358979323846264338327950288;
const ld eps=1e-13;
const ll mod=1e9+7;

int main(){
    CPPinput;
    int n; cin>>n;
    set<int> st;
    vector<int> v;
    for(int i=0;i<n;++i){
        int t; cin>>t;
        if(i&1)st.insert(t);
        v.pb(t);
    }
    sort(v.begin(),v.end());
    int diff=0;
    for(int i=1;i<n;i+=2){
        if(st.find(v[i])==st.end())++diff;
    }
    cout<<diff<<endl;
}


Measured memory_bytes: 3064
#include<stdio.h>

int main(void){
	int n,min=0,cnt=1;
	scanf("%d",&n);
	int p[n];
	for(int i=0;i<n;i++){
		scanf("%d",&p[i]);
	}
	min=p[0];
	for(int i=1;i<n;i++){
		if(min>=p[i]){
			min=p[i];
			cnt+=1;
		}
	}


	printf("%d",cnt);
	return 0;
}


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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef double db;

int main() {
    ios_base::sync_with_stdio( false );
    cin.tie( nullptr );
    ld pi = acos(-1.0);
    int R;
    cin >> R;
    cout << pi * 2 * R << '\n';
    return 0;
}


Measured memory_bytes: 3788
#include <iostream>
#include <vector>
#include <string>
#include <cmath>

using namespace std;
using ll = long long;
using ull = unsigned long long;

constexpr ll LLINF {1001002003004005006};//ll = 9*LLINF

#define  rep(i,n)   for(int i = 0; i < (n); ++i)
#define rrep(i,n)   for(int i = 1; i <= (n); ++i)
#define drep(i,n)   for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for(int i = s; i < t;  ++i)

#define maxs(x,y) (x=std::max(x,y))
#define mins(x,y) (x=std::min(x,y))

int main() {
  int K, X;
  cin >> K >> X;
  int min_value = X - K + 1;
  int max_value = X + K - 1;
  bool is_first = true;
  for (auto i = min_value; i <= max_value;++i) {
    if (is_first) {
      is_first = false;
    } else {
      cout << ' ';
    }
    cout << i;
  }
  cout << '\n';
}


Measured memory_bytes: 504
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <cstdio>
#include <ctime>
#include <assert.h>
#include <chrono>
#include <random>
#include <numeric>
#include <set>
#include <deque>
#include <stack>
using namespace std;
typedef long long int ll;
typedef unsigned long long ull;

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll myRand(ll B) {
    return (ull)rng() % B;
}

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int R,N;
	while(cin >> R >> N){
		if(R==0)break;
		vector<int> h(41,0);
		for(int i=0;i<N;i++){
			int l,r,hh; cin >> l >> r >> hh;
			for(int x=l+20;x<r+20;x++){
				h[x]=max(h[x],hh);
			}
		}
		double res=25;
		for(int x=-R+1;x<R;x++){
			int hh=min(h[x+20],h[x+19]);
			res=min(res,hh-sqrt(R*R-x*x)+R);
		}
		printf("%.8lf\n",res);
	}
}



Measured memory_bytes: 3244
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        double x1 = sc.nextDouble();
        double y1 = sc.nextDouble();
        double x2 = sc.nextDouble();
        double y2 = sc.nextDouble();

        double distance = Math.sqrt(Math.pow(x1-x2, 2)+Math.pow(y1-y2, 2));
        System.out.println(distance);
    }
}


Measured memory_bytes: 28032
#include<bits/stdc++.h>
#define ll long long
#define nl "\n"
#define pi acos(-1)
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define pcase printf("Case %d:\n",ca)
int ca=1;
using namespace std;
int main(){
    double n,x,t;
    cin>>n>>x>>t;
    int ans = ceil(n/x)*t;
   cout<<ans<<nl;
}



Measured memory_bytes: 3688
//#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"

#define rep(i,n) for(ll (i)=0;(i)<(ll)(n);(i)++)
#define all(x) (x).begin(),(x).end()

#define MOD 1000000007LL
#define INF (1LL<<60LL)
#define int long long
#define MAX_N (100001)
typedef long long ll;

using namespace std;


vector<vector<bool>> v(100, vector<bool>(100,1));



signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int a, b; cin >> a >> b;
	bool rev = false;
	if (a > b) {
		swap(a, b);
		rev = true;
	}
	int i = 0, j = 0;
	if (b > 1)a--;
	rep(_, a) {
		v[i][j] = 0;
		j += 2;
		if (j >= 100) {
			i++;
			j = i % 2;
		}
	}
	b -= max(0LL, a - 50);
	i += 3;
	j = 1;
	rep(_, b-1) {
		rep(i2, 3)rep(j2, 3) {
			v[i + i2 - 1][j + j2 - 1] = 0;
		}
		v[i][j] = 1;
		j += 2;
		if (j >= 98) {
			i+=2;
			j = 1;
		}
	}
	char m[2];
	if (!rev) {
		m[0] = '.';
		m[1] = '#';
	}else  {
		m[1] = '.';
		m[0] = '#';
	}
	cout << 100 << " " << 100 << "\n";
	rep(i2, 100)rep(j2, 100) {
		cout << m[v[i2][j2]];
		if (j2 == 99) cout << "\n";
	}
}

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

using namespace std;

/**************************************************************/

#define int long long
#define tie() ios_base :: sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define f(i,from,to) for(int i = from ; i <to ; i++)
#define mem(a , v) memset(a , v , sizeof a)
#define all(v) v.begin() , v.end()
#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#define what_is(x) cerr << #x << " is : " << x <<endl

const int INF = 1e9 + 7;
const int sz = 1e5 + 20;
const int N =1e5 + 20;
/***************************************************************/

void solve()
{
    string a , b;
    cin >> a >> b;
    b += a;
    cout << b << endl;
    return;
}


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


Measured memory_bytes: 256
import math
import cmath

A, B, H, M = [int(x) for x in input().split()]

minuteTheta = 2.0 * math.pi * M / 60.0
hourTheta = 2.0 * math.pi * (H / 12.0 + M / (60.0 * 12.0))

mvec = cmath.rect(B, minuteTheta)
hvec = cmath.rect(A, hourTheta)

print(abs(mvec - hvec))



Measured memory_bytes: 62916
n=int(input())
w=[]
for i in range(n):
    w.append(str(input()))

w_u = sorted(set(w), key=w.index)
flag=False
if len(w_u)!=len(w):
    flag=True
else:
    for i in range(1,len(w)):
        if w[i-1][-1]==w[i][0]:
            pass
        else:
            flag=True
            break

print("YNeos"[flag::2])


Measured memory_bytes: 3064
N = int(input())
A = list(map(int,input().split()))
amax = -10**7
amin = 10**7
indexmax = 51
indexmin = 51
print(2*N-1)
for i in range(N):
	if amax < A[i]:
		amax = A[i]
		indexmax = i
	if amin > A[i]:
		amin = A[i]
		indexmin = i
if abs(amax) >= abs(amin):
	for i in range(N):
		print(indexmax+1, end=' ')
		print(i+1)
	for i in range(N-1):
		print(i+1, end=' ')
		print(i+2)
else:
	for i in range(N):
		print(indexmin+1, end=' ')
		print(i+1)
	for i in range(N-1):
		print(N-i, end=' ')
		print(N-i-1)
	
	 


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define int long long
struct node{
  int key;
  node *left,*right,*p;
  node(){}
  node(int key):key(key){left=right=p=NULL;};
};
node *root;
void insert(node z){
  node *y=NULL;
  node *x=root;
  while(x!=NULL){
    y=x;
    if(z.key<x->key) x=x->left;
    else x=x->right;
  }
  z.p=y;
  if(y==NULL) root=new node(z);
  else if(z.key<y->key) y->left=new node(z);
  else y->right=new node(z);
}
void inorderTreeWalk(node *v){
  if(v==NULL) return;
  inorderTreeWalk(v->left);
  cout<<" "<<v->key;
  inorderTreeWalk(v->right);
}
void preorderTreeWalk(node *v){
  if(v==NULL) return;
  cout<<" "<<v->key;
  preorderTreeWalk(v->left);
  preorderTreeWalk(v->right);
}
signed main(){
  int n;
  cin>>n;
  root=NULL;
  for(int i=0;i<n;i++){
    string s;
    cin>>s;
    //cout<<(root==NULL?-1:root->key)<<endl;
    if(s=="print"){
      inorderTreeWalk(root);
      cout<<endl;
      preorderTreeWalk(root);
      cout<<endl;
      continue;
    }
    int x;
    cin>>x;
    insert(node(x));
  }
  return 0;
}

Measured memory_bytes: 26440
// id: ALDS1_3_A
// CPU: 00:00sec  Memory: 2864KB
#include <cstdio>
#include <stack>
#include <string>
#include <cctype>

using std::stack;
using std::string;
using std::stoi; // 新标准函数，oj要选用C++11

static const int MAX_LEN = 6;

int main()
{
	stack<int> opds;
	char str[MAX_LEN + 1];

	while ( scanf("%s", str) != EOF ) {
		string s(str);

		if ( isdigit(s[0]) )
			opds.push(stoi(s));
		else {
			int rhs = opds.top();
			opds.pop();
			int lhs = opds.top();
			opds.pop();

			if ( s == "+" )
				opds.push(lhs + rhs);
			else if ( s == "-" )
				opds.push(lhs - rhs);
			else
				opds.push(lhs * rhs);
		}
	}

	printf("%d\n", opds.top());

	return 0;
}


Measured memory_bytes: 2796
#include<bits/stdc++.h>
using namespace std;
int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int H, W;
    cin >> H >> W;
    int white = 0;
    vector<vector<bool> > B(H, vector<bool>(W, false));
    for (int i = 0; i < H; i++) {
        string S;
        cin >> S;
        for (int j = 0; j < W; j++) {
            if (S[j] == '.') {
                white++;
                B[i][j] = true;
            }
        }
    }
    int count = 0;
    queue<pair<int, int> > Q, QQ;
    Q.push(make_pair(0, 0));
    B[0][0] = false;
    while (!Q.empty()) {
        swap(Q, QQ);
        count++;
        while (!QQ.empty()) {
            pair<int, int> q = QQ.front();
            int i = q.first, j = q.second;
            if (i == H-1 && j == W-1) {
                printf("%d\n", white-count);
                return 0;
            }
            if (i != 0 && B[i-1][j]) {
                Q.push(make_pair(i-1, j));
                B[i-1][j] = false;
            }
            if (i != H-1 && B[i+1][j]) {
                Q.push(make_pair(i+1, j));
                B[i+1][j] = false;
            }
            if (j != 0 && B[i][j-1]) {
                Q.push(make_pair(i, j-1));
                B[i][j-1] = false;
            }
            if (j != W-1 && B[i][j+1]) {
                Q.push(make_pair(i, j+1));
                B[i][j+1] = false;
            }
            QQ.pop();
        }
    }
    printf("-1\n");
    return 0;
}

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

int n, y, m, d;


int main() {
  cin >> n;
  for(int i = 0; i < n; i++) {
    int cnt = 0;
    cin >> y >> m >> d;
    while(!(y == 1000 && m == 1 && d == 1)){
      if(y % 3 == 0) {
	if(m == 10 && d == 20) {
	  d = 1; m = 1; y++; cnt++;
	}
	else if(d == 20) {
	  d = 1; m++; cnt++;
	}
	else d++, cnt++;
      }else {
	if(m % 2 == 0){
	  if(m == 10 && d == 19) {
	    d = 1; m = 1; y++; cnt++;
	  }else if(d == 19) {
	    d = 1; m++; cnt++;
	  }else d++, cnt++;
	}else {
	  if(d == 20) {
	    d = 1; m++; cnt++;
	  }else d++, cnt++;
	}
      }
    }
    cout << cnt << endl;
  }
}

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

int main(){
  int N;
  cin >> N;
  string S;
  cin >> S;
  string T;
  cin >> T;
  for (int i=0;i<N;i++){
    cout << S.at(i) <<T.at(i);
    if(i==N-1){
      cout << endl;
    }
  }
}

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

using ll=long long;
#define int ll

#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define pb push_back
#define eb emplace_back
#define a first
#define b second
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
#ifdef LOCAL
#define dmp(x) cerr<<__LINE__<<" "<<#x<<" "<<x<<endl
#else
#define dmp(x) void(0)
#endif

template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}

template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;

using pi=pair<int,int>;
using vi=vc<int>;

template<class t,class u>
ostream& operator<<(ostream& os,const pair<t,u>& p){
	return os<<"{"<<p.a<<","<<p.b<<"}";
}

template<class t> ostream& operator<<(ostream& os,const vc<t>& v){
	os<<"{";
	for(auto e:v)os<<e<<",";
	return os<<"}";
}

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout<<fixed<<setprecision(20);
	
	const int L=200010;
	
	vvc<int> id(L*2,vi{-1});
	id[L].pb(0);
	
	int cur=0;
	vi h{0};
	vi cnt{0};
	
	string qs;cin>>qs;
	
	auto ad=[&](int x){
		int p=id[x+L-1].back();
		int w=id[x+L].ed-upper_bound(all(id[x+L]),p);
		cur+=w;
		cnt.pb(w);
		id[x+L].pb(h.size());
		h.pb(x);
	};
	
	for(auto c:qs){
		if(c=='('){
			int x=h.back()+1;
			ad(x);
		}else if(c==')'){
			int x=h.back()-1;
			ad(x);
		}else{
			cur-=cnt.back();
			cnt.pop_back();
			
			int x=h.back();
			h.pop_back();
			id[x+L].pop_back();
		}
		cout<<cur<<"\n";
	}
}



Measured memory_bytes: 30880
def main():
    n = int(input())
    d, x = map(int, input().split())
    a_ = []
    for _ in range(n):
        a_.append(int(input()))

    l = []
    for i in range(1, 101):
        for a in a_:
            r = (i - 1) * a + 1
            if r <= d:
                l.append(r)

    print(len(l) + x)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
from fractions import gcd

def lcm(x, y):
    return (x * y) // gcd(x, y)

A, B, C, D = map(int, input().split())

div_A_C = (A-1)//C
div_A_D = (A-1)//D

div_B_C = B//C
div_B_D = B//D

CD = lcm(C, D)

div_A_CD = (A-1)//CD
div_B_CD = B // CD
C_or_D = (div_B_C+div_B_D-div_B_CD)-(div_A_C+div_A_D-div_A_CD) 
print(B-A+1-C_or_D)

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

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

	int len = w.size();
	for (int i = 'a'; i <= 'z'; i++) {
		int count = 0;
		for (int j = 0; j < len; j++) {
			if (w[j] == i)
				count++;
		}
		if (count % 2) {
			cout << "No" << endl;
			return 0;
		}
	}

	cout << "Yes" << endl;
}

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

using namespace std;
typedef long long ll;
int main() 
{
	ll n, m, i;
	ll a[100000];
	cin >> n >> m;
	ll sum = 0;
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	sort(a, a + n);
	for(i = 0; i < n; i++){
		sum += a[i];
		if(sum > m){
			break;
		}
	}
	if(sum < m){
		i--;
	}
	cout << i;
}

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

using namespace std;

int main() {
    long long a = 0;
    long long b = 0;
    long long n = 0;
    cin >> a >> b >> n;

    long long result = 0;

    if(n >= b && n != 1){
        n = (n / b) * b - 1;
    }

    long double A = (long double)a * (long double)n / (long double)b;
    long double B = (long double)n / (long double)b;

    result = (long long)A - a * (long long)B;
    
    cout << result << endl;
    return 0;
}

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

ans = ''
for s in S:
    to_a_cost = (26 - (ord(s) - 97)) % 26
    if to_a_cost <= K:
        ans += 'a'
        K -= to_a_cost
    else:
        ans += s


if K:
    K %= 26
    ans = ans[:-1] + chr(97 + (((ord(ans[-1]) - 97) + K) % 26))

print(ans)


Measured memory_bytes: 3444
#include "bits/stdc++.h"
using namespace std;
int main()
{
	int n, m;
	scanf("%d %d", &n, &m);
	vector<int> a(n, 0);
	for(int i = 0, j, k; i < m; i++)
	{
		scanf("%d %d", &j, &k);
		a[--j]++;
		a[--k]++;
	}
	for(int i = 0; i < n; i++)
	{
		printf("%d\n", a[i]);
	}
}

Measured memory_bytes: 256