akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
 
using namespace std;

 

int dp[100000];

int minCost(vector<int> ar,int i){
    if(i<=0){
        return 0;
    }
    if(i==1){
        return abs(ar[i]-ar[i-1]);
    }
    if(dp[i]!=-1){
        return dp[i];
    }
    int a=minCost(ar,i-1);
    int b=minCost(ar,i-2);
    dp[i]=min(a + abs(ar[i]-ar[i-1]),b + abs(ar[i]-ar[i-2]));
    return dp[i];
}

int32_t main(){
    int t;
    cin>>t;
    //memset(dp,-1,100000);
    vector<int> h(t);
    for(int i=0;i<t;i++){
        cin>>h[i];
    }
    vector<int> a(t,0);
    a[0]=0;
    a[1]=abs(h[1]-h[0]);
    for(int i=2;i<t;i++){
        a[i] = min(a[i-1]+abs(h[i]-h[i-1]), a[i-2]+abs(h[i]-h[i-2]));
    }
    cout<<a[t-1]<<endl;
    //cout<<minCost(h,h.size()-1)<<endl;
}


Measured memory_bytes: 1024
n, k = map(int, input().split())

if (n - 1) * (n - 2) // 2 < k:
    print(-1)
    exit()

ans = []
for i in range(n-1):
    ans.append((i, n-1))

cnt = (n - 1) * (n - 2) // 2

for i in range(n-1):
    for j in range(i+1, n-1):
        if cnt > k:
            ans.append((i, j))
            cnt -= 1

print (len(ans))
for a in ans:
    print(a[0]+1, a[1]+1)

Measured memory_bytes: 3956
from sys import exit, setrecursionlimit, stderr
from functools import reduce
from itertools import *
from collections import defaultdict
from bisect import bisect

def read():
  return int(input())

def reads():
  return [int(x) for x in input().split()]

N, M = reads()
cond = []
for _ in range(M):
  a, b = reads()
  cond.append((a-1, b-1))
cond.sort()

count = 0
end = -1
for a, b in cond:
  if a < end:
    end = min(end, b)
  else:
    count += 1
    end = b
print(count)

Measured memory_bytes: 56872
#include <bits/stdc++.h>
#ifdef DEBUG
#include "_debug.cpp"
#include "callable.hpp/callable.hpp"
#endif
#define endl '\n'
using namespace std;
using ll = long long;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    vector<int> c(n);
    for(int i = 0; i < n; i++) {
        cin >> c[i];
    }
    sort(c.begin(), c.end());
    int a = 0, b = 0;
    for(int i = 0; i < n; i++) {
        (i % 2 ? b : a) += c[i];
    }
    cout << abs(b - a) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
/* clang-format off */
#define MOD 1000000007
#define INF 1000000000
#define REP(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(a) (a).begin(), (a).end()
#define __DEBUG__
#ifdef __DEBUG__
#define CH_P(a) cout <<"check_point("<<#a<<")" << "\n";
#define DEBUG(x) cout<<#x<<":"<<x<<"\n"
#define DEBUGS(v) cout << #v << ":";for(auto x:v){cout<<x<<" ";}cout<<"\n"
#endif
#ifndef __DEBUG__
#define CH_P(a) 
#define DEBUG(x) 
#define DEBUGS(v) 
#endif
#define TIMER_S(start) chrono::system_clock::time_point start = chrono::system_clock::now();
#define TIMER_E(end) chrono::system_clock::time_point end = chrono::system_clock::now();
#define TIME(start, end) cout << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count()) << "ms" << "\n";
/* clang-format on */

ll d;
vector<ll> c(26);
vector<vector<ll>> s(365, vector<ll>(26));
vector<ll> t(365);
vector<ll> last(26, -1);

ll score(ll type, ll day, ll sc) {
  ll s_now = sc + s[day][type];
  REP(i, 26) { s_now -= c[i] * (day - last[i]); }
  return s_now;
}

int main() {
  cin >> d;
REP(i, 26) { cin >> c[i]; }

    REP(i, d) {
      REP(j, 26) { cin >> s[i][j]; }
    }

  REP(i, d) {
    cin >> t[i];
    t[i]--;
  }

  ll ss = 0;
  REP(i, d) {
    last[t[i]] = i;
    cout << score(t[i], i, ss) << "\n";
    ss = score(t[i], i, ss);
  }
  return 0;
}


Measured memory_bytes: 3608
/*suri_kumkaran*/

#include <bits/stdc++.h>

using namespace std;

#define UB upper_bound
#define LB lower_bound
#define BS binary_search
#define MP make_pair
#define EB emplace_back
#define endl "\n"
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define F first
#define S second
#define ALL(a) (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)

typedef long long int int64;
typedef vector<int64> VI64;
typedef vector<pair<int64,int64>> VII64;
typedef vector<string> VS;
typedef vector<vector<int64>> VVI;

int main()
{
	IOS;
	int64 T=1;
	//cin>>T;
	while(T--)
	{
		int64 h;
		cin>>h;
		map<int64,int64> mp;
		mp[h]=1;
		int64 ans=0;
		while(mp.size())
		{
			auto x=mp.begin();
			int64 val=x->F;
			int64 freq=x->S;
			//cout<<val<<" "<<freq<<endl;
			mp.erase(x);
			if(val==1)
				ans+=freq;
			else
			{
				ans+=freq;
				mp[val/2]+=2*freq;
			}
		}
		cout<<ans;
	}

	return 0;
}

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

int main(void){
    int N, K, xi, yi, s;
    char C;
    cin >> N >> K;
    int XY[4005][4005];
    int ans=0;
    for(int i = 0 ;i < N ; i++){
        cin >> xi >> yi >> C;
        if(C == 'B') xi += K;
        XY[xi % (2*K)+1][yi % (2*K)+1]++;
        XY[xi % (2*K)+1+2*K][yi % (2*K)+1+2*K]++;
        XY[xi % (2*K)+1][yi % (2*K)+1+2*K]++;
        XY[xi % (2*K)+1+2*K][yi % (2*K)+1]++;
    }

    for(int i=1;i<=4*K;i++){
		for(int j=1;j<=4*K;j++){
			XY[i][j] += -XY[i-1][j-1] +XY[i-1][j]+XY[i][j-1];
		}
	}
	for(int i=1;i<=2*K;i++){
		for(int j=1;j<=2*K;j++){
			s=XY[i+K][j+K]-XY[i][j+K]-XY[i+K][j]+XY[i][j];
            s+=XY[i+K +K][j+K +K]-XY[i +K][j+K +K]-XY[i+K +K][j +K]+XY[i +K][j +K];
            ans = max(ans, s);
            ans = max(ans, N-s);
		}
	}
	cout << ans << endl;
    return 0;
}


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

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  if(a==b&&b==c){
    cout << 1 << endl;
  }
  else if(a==b||a==c||b==c){
    cout << 2 << endl;
  }
  else{
    cout << 3 << endl;
  }
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <iostream>
#include <vector>
#include <stdio.h>
#include <bits/stdc++.h>


using namespace std;
#define ll long long
#define ld long double
#define  P pair<ll,ll>
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORa(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define FORr(i,m,n) for(ll i=n; i>=(ll)m; i--)
#define FORm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define FORs(i,st) for(auto i : st)
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define ALL(c) (c).begin(), (c).end()
#define VEC2(x,a,b) vector<vector<ll>> x = vector<vector<ll>>(a,vector<ll>(b,0))
#define sortAl(v) sort(v.begin(),v.end())
#define sortAlr(v) sort(v.begin(),v.end()); reverse(v.begin(),v.end())
#define cinv(v,n,m) FOR(i,n,m) cin>>v.at(i)
#define coutv(v,n,m) FOR(i,n,m) cout<<v.at(i) <<" "; cout<<endl
#define cout(n) cout<<fixed<<setprecision(n)

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,l;
    cin>>n>>l;
    while(n!=0){
      ll res=0;
      ll most_left_1 = 0;
      ll most_right_1 = 0;
      ll num_left_1 = -1;
      ll most_left_2 = 0;
      ll most_right_2 = 0;
      ll num_left_2 = -1;

      vector<ll> ant1;
      vector<ll> ant2;
      FOR(i,0,n){
        char c;
        ll p;
        cin>>c>>p;
        res = (c == 'L' ? max(res,p) : max(res,l-p));
        if(p % 2 == 0){
          if(c == 'L'){
            num_left_1++;
            most_left_1 = max(most_left_1, p);
          }
          else most_right_1 = max(most_right_1, l-p);
          ant1.push_back(i);
        }
        else{
          if(c == 'L'){
            num_left_2++;
            most_left_2 = max(most_left_2, p);
          }
          else most_right_2 = max(most_right_2, l-p);
          ant2.push_back(i);
        }
      }
      ll flag1 = 1;
      if(most_left_1<most_right_1){
        num_left_1++;
        flag1=0;
      }
      if(most_left_2<most_right_2){
        num_left_2++;
      }
      ll x = max(most_left_1,most_right_1);
      ll y = max(most_left_2,most_right_2);
//      cout<<x<<" "<<y<<endl;
      ll ans = (x>y ? ant1[num_left_1] : ant2[num_left_2]);
      if(x==y) ans = (flag1 ? ant1[num_left_1] : ant2[num_left_2]);

//      cout<<num_left_1<<" "<<num_left_2<<endl;
      cout<<res<<" "<<ans+1<<endl;
      cin>>n>>l;
    }
}



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

int main() {
  int a, b, c, d, l, r;
  cin >> a >> b >> c >> d;

  l = a + b;
  r = c + d;
  if (l > r) {
    cout << "Left" << endl;
  }
  else if (l == r){
    cout << "Balanced" << endl;
  }
  else {
  	cout << "Right" << endl;
  }
}

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

int main(void)
{
  int N;
  scanf("%d", &N);
  int A[N+2], dist[N+1], sum = 0;
  A[0] = A[N+1] = 0;
  for(int i = 1; i <= N; i++){
    scanf("%d", &A[i]);
    sum += dist[i-1] = abs(A[i-1]-A[i]);
  }
  sum += dist[N] = abs(A[N]);
  for(int i = 1; i <= N; i++){
    int ans = sum-dist[i-1]-dist[i]+abs(A[i-1]-A[i+1]);
    printf("%d\n", ans);
  }
}


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

struct Node {
  int key;
  Node *right, *left, *parent;
};

Node *root, *NIL;

void insert(int k){
  Node *y = NIL;
  Node *x = root;
  Node *z;

  z = (Node *)malloc(sizeof(Node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while( x != NIL ) {
    y = x;
    if( z->key < x->key) {
      x = x->left;
    } else {
      x = x->right;
    }
  }
  z->parent = y;
  if ( y == NIL ){
    root = z;
  } else {
    if (z->key < y->key) {
      y->left = z;
    } else {
      y->right = z;
    }
  }
}
void inorder(Node *u){
  if ( u == NIL) return;
  inorder(u->left);
  printf(" %d", u->key);
  inorder(u->right);
}

void preorder(Node *u){
  if( u == NIL) return;
  printf(" %d", u->key);
  preorder(u->left);
  preorder(u->right);
}

int main(){
	int n, i, x;
  string com;

  scanf("%d", &n);

  for (i = 0; i < n; i++ ) {
    cin >> com;
    if (com == "insert") {
      scanf("%d", &x);
      insert(x);
    } else if (com == "print"){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }

  return 0;
}



Measured memory_bytes: 26768
#include <bits/stdc++.h>
#define INF 1e9
#define endl '\n'
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); --i)
#define FORE(i, a, b) for (int i = (a), e = (b); i < e; ++i)
#define RFORE(i, a, b) for (int i = (b)-1, e = (a); i >= e; --i)
#define ALL(x) (x).begin(), (x).end()
#define SORT(c) sort((c).begin(), (c).end())
#define SORTR(c) sort((c).begin(), (c).end(), greater<int>())
using namespace std;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int W, H, N;
    cin >> W >> H >> N;
    int X = 0;
    int Y = 0;
    for (int i = 0; i < N; i++) {
        int x, y, a;
        cin >> x >> y >> a;
        switch (a) {
            case 1: X = X < x ? x : X; break;
            case 2: W = x < W ? x : W; break;
            case 3: Y = Y < y ? y : Y; break;
            case 4: H = y < H ? y : H; break;
        }
    }
    cout << max(W - X, 0) * max(H - Y, 0) << endl;
}


Measured memory_bytes: 3652
macro_rules! get {
      ($t:ty) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              line.trim().parse::<$t>().unwrap()
          }
      };
      ($($t:ty),*) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              let mut iter = line.split_whitespace();
              (
                  $(iter.next().unwrap().parse::<$t>().unwrap(),)*
              )
          }
      };
      ($t:ty; $n:expr) => {
          (0..$n).map(|_|
              get!($t)
          ).collect::<Vec<_>>()
      };
      ($($t:ty),*; $n:expr) => {
          (0..$n).map(|_|
              get!($($t),*)
          ).collect::<Vec<_>>()
      };
      ($t:ty ;;) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              line.split_whitespace()
                  .map(|t| t.parse::<$t>().unwrap())
                  .collect::<Vec<_>>()
          }
      };
      ($t:ty ;; $n:expr) => {
          (0..$n).map(|_| get!($t ;;)).collect::<Vec<_>>()
      };
}

fn main() {
    let (a, b) = get!(usize, usize);

    if a * b % 2 == 0 {
        println!("Even")
    } else { 
        println!("Odd")
    }
}


Measured memory_bytes: 4352
a, b, c = map(int, input().split())
k = int(input())

for i in range(k):
    if a >= c:
        c *= 2
    elif a >= b:
        b *= 2
    elif b >= c:
        c *= 2

if a < b and b < c:
    print('Yes')
else:
    print('No')


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

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;
#define DEBUG freopen("in.txt", "r", stdin);

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;

const int N = 55556;
int n, m, k, ans;
bool P[N];

int main() {
    fill(P, P + N, true);
    for (int i = 2; i <= N; ++i) {
        if (P[i]) {
            for (int j = i + i; j <= N; j += i) {
                P[j] = false;
            }
        }
    }
    cin >> n;
    --n;
    cout << 7 << ' ';
    for (int i = 8; i <= N; ++i) {
        if (!n) break;
        if (P[i] && i % 10 == 7) {
            --n;
            cout << i << ' ';
        }
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3672
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
#define int long long
using namespace std;
typedef pair<int,int>P;
typedef pair<int,P>P2;
#define fi first
#define se second

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


signed main(){
  int n,sum=0;
  cin>>n;
  r(i,n){
    int a;
    cin>>a;
    if(a%2==0)sum++;
  }
  if(sum==n)cout<<"second"<<endl;
  else cout<<"first"<<endl;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <cmath>
#include<iomanip>
using namespace std;

double rad(int x);

int main() {
	int a, b, C;
	cin >> a >> b >> C;
	double S, L, h;
	S = 0.5*a*b*sin(rad(C));
	L = sqrt(a*a + b*b-2*a*b*cos(rad(C)))+a+b;
	h = S * 2 / a;
	cout <<setprecision(20)<< S <<endl;
	cout << L << endl;
	cout << h << endl;

}

double rad(int x) {
	return 1.0*x*M_PI/180;
}

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

int main(){
    string s;
    cin >> s;
    bool b = true;
    string ans;
    while(b){
        string t5,t6,t7;
        if(s.size() < 5) b = false;
        if(s.size() >= 5) t5 = s.substr(s.size()-5);
        if(s.size() >= 6) t6 = s.substr(s.size()-6);
        if(s.size() >= 7) t7 = s.substr(s.size()-7);
        if(t5 == "erase" && b) s = s.substr(0,s.size()-5);
        else if(t5 == "dream" && b) s = s.substr(0,s.size()-5);
        else if(t6 == "eraser" && b) s = s.substr(0,s.size()-6);
        else if(t7 == "dreamer" && b) s = s.substr(0,s.size()-7);
        else{
            ans = "NO";
            b = false;
        }
        if(s.size() == 0){
            ans = "YES";
            b = false;
        }
    }
    cout << ans << endl;
}

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

int main()
{
    string a,b;
    cin>>a>>b;
    int n = a.length();
    int m = b.length();
    int dp[n+1][m+1];
    for(int i=0;i<=n;i++){
        for(int j=0;j<=m;j++){
            dp[i][j] = 0;
        }
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            if(a[i-1]==b[j-1]){
                dp[i][j] = 1+dp[i-1][j-1];
            }
            else{
                dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
            }
        }
    }
    int index = dp[n][m];
    int i=n,j=m;
    string ans = "";
    while(i>0&&j>0){
        if(a[i-1]==b[j-1]){
            ans+=a[i-1];
            index--;
            i--;j--;
        }
        else if(dp[i-1][j]>dp[i][j-1]){
            i--;
        }
        else
            j--;
    }
    i = 0;
    j = ans.length()-1;
    while(i<j){
        char c = ans[i];
        ans[i] = ans[j];
        ans[j] = c;
        i++;
        j--;
    }
    cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 35456
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,pprint,fractions
sys.setrecursionlimit(10**8)
mod = 10**9+7
mod2 = 998244353
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

s = input()
n = len(s)
d = [0,0,0]
for t in s:
    if t == 'a':
        d[0] += 1
    elif t == 'b':
        d[1] += 1
    else:
        d[2] += 1
m = min(d)
# print(m)
for i in range(3):
    d[i] -= m
# print(d)
print('YES' if max(d) < 2 else 'NO')

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

#define FOR( i, m, n )  for( int (i) = (m); (i) < (n); (i)++ )
#define REP( i, n )     FOR( i, 0, n )
#define ALL( a )        (a).begin(), (a).end()             

int main() {
	int x, y, s;
	while( 1 ) {
		cin >> x >> y >> s;
		if( x == 0 && y == 0 && s == 0 ) break;

		int tmax = 0;
		int m1, m2;
		FOR( i, 1, s / 2 + s % 2 + 1 ) {
			for( int j = s - i;; j-- ) {
				m1 = i * ( 100 + x ) / 100;
				m2 = j * ( 100 + x ) / 100;
				if( m1 + m2 < s ) break;
				if( m1 + m2 == s ) {
					m1 = i * ( 100 + y ) / 100;
					m2 = j * ( 100 + y ) / 100;
					tmax = max( m1 + m2, tmax );
				}
			}
		}

		cout << tmax << endl;
	}
	
}


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

int main()
{
    int a,b,t;
    cin >> a >> b >> t;
    cout << b*(t/a) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N = 404, M = 100005;
int n, m, A[M], B[M];
bitset < N > S[N];
int main()
{
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= m; i++)
		scanf("%d%d", &A[i], &B[i]);
	for (int i = 1; i <= n; i++)
	{
		S[i][i] = 1;
		for (int j = m; j; j --)
		{
			if (S[i][A[j]] && S[i][B[j]])
			{
				for (int h = 1; h <= n; h++)
					S[i][h] = 1;
				break;
			}
			else if (S[i][A[j]])
				S[i][B[j]] = 1;
			else if (S[i][B[j]])
				S[i][A[j]] = 1;
		}
	}
	int cnt = 0;
	for (int i = 1; i <= n; i++)
		for (int j = i + 1; j <= n; j++)
			if (!(S[i] & S[j]).count())
				cnt ++;
	return !printf("%d\n", cnt);
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    multiset<int> s;
    s.insert(a[0]);
    for(int i = 1; i < n; i++)
    {
        auto itr = s.lower_bound(a[i]);
        if(itr == s.begin())
        {
            s.insert(a[i]);
        }
        else
        {
            itr--;
            s.erase(itr);
            s.insert(a[i]);
        }
    }
    cout << s.size() << endl;
}


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

int main() {
  string a = " Eve";
  int b;
  string c;
  c += "Christmas";
  cin >> b;
  if(b == 25){
    cout << c << endl;
  }else if(b == 24){
    cout << c + a << endl;
  }else if(b == 23){
    cout << c +a +a<< endl;
  }else if(b == 22){
    cout << c +a+a+a<< endl;
  }
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
   int N = sc.nextInt();
   int[] An = new int[N];
   for(int i =0;i<N;i++){
   An[i] = sc.nextInt();
   }
   int max = 0;
   int max2 = 0;
   if(An[0]<=An[1]){
   max = An[1];
   max2 = An[0];
   }else{
   max = An[0];
   max2 = An[1];
   }
     
   
   for(int i =2;i<N;i++){
    if(max<=An[i]){
      max2 = max;
      max = An[i];
    }else if(max2<=An[i]) max2 = An[i];
   }
   for(int i = 0;i <N; i++){
     if(An[i]==max) System.out.println(max2);
     else System.out.println(max);
   }

 }
}

Measured memory_bytes: 107484
import sys

A, B = sys.stdin.readline().strip().split()
A = int(A)
for i in range(1000):
    if i < 10:
        s = "0.0" + str(i)
    elif i < 100:
        s = "0." + str(i)
    else:
        i = str(i)
        s = i[0] + "." + i[1:]
    if B == s:
        B = int(i)
print(A*B // 100)

Measured memory_bytes: 9152
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include <unordered_map>
//#include"testlib.h"
#define endl "\n"
#define all(v) v.begin(),v.end()
#define allr(s) s.rbegin(),s.rend()
#define RT(s) return cout<<s,0
#define watch(x) cout << (#x)<<" = "<<x<<endl
#define sz(s)    (int)(s.size())
#define PI acos(-1)
#define EPS 1e-8
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
int dy[] = { 1, -1, 0, 0, -1, 1, 1, -1 };
int dx[] = { 0, 0, 1, -1, 1, -1, 1, -1 };
void file() {
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
#else
	//freopen("street.in", "r", stdin);
	//freopen("out.txt", "w", stdout);
#endif
}
void fast() {
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL);
}

int main() {
//	file();
	fast();
	long long a, b, c;
	cin >> a >> b >> c;
	if (a == b && c != a) RT("Yes" << endl);
	if (a == c && b != a) RT("Yes" << endl);
	if (b == c && a != b) RT("Yes" << endl);
	cout << "No" << endl;
	return 0;
}



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

const std::string ans[2] = {"No\n", "Yes\n"};
// constexpr ll MOD         = 1'000'000'007;
// constexpr ll MOD         = 998'244'353;

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

    sort(a, a + n);
    int max_dis = k - a[n - 1] + a[0];
    for (int i = 1; i < n; i++) {
        if (a[i] - a[i - 1] > max_dis) {
            max_dis = a[i] - a[i - 1];
        }
    }
    cout << k - max_dis << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define MOD (1000000007)
#define vi vector<int>
#define vl vector<ll>
#define vb vector<bool>
#define vvi vector<vi>
#define vvl vector<vl>
#define pii pair<int, int>
#define pli pair<ll, int>a
#define pb push_back

#define mp make_pair
#define all(a) (a).begin(),(a).end()

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

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

ll keta(ll n){
  string s = to_string(n);
  ll num = s.size();
  return num;
}

const ll INF = 1LL << 60;

const int dh[4] = {1,0,-1,0};
const int dw[4] = {0,1,0,-1};

struct Edge{
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w){}
};
using Graph = vector<vector<Edge>>;
using P = pair<ll, int>;

class UnionFind{
  public:
  vi Parent;
  UnionFind(int n){
    Parent = vi(n,-1);
  }

  int root(int a){
    if(Parent[a] < 0) return a;
    else return Parent[a] = root(Parent[a]);
  }

  int size(int a){
    return -Parent[root(a)];
  }

  bool merge(int a, int b){
    a = root(a);
    b = root(b);
    if(a == b) return false;

    if(size(a) < size(b)) swap(a,b);
    Parent[a] += Parent[b];
    Parent[b] = a;

    return true;
  }
};

class Factrial{
  public:
  vl Fac;
  Factrial(int MAX){
    Fac = vl(MAX+1);
    rep(i,MAX) {
      if(i == 0) Fac[i+1] = 1;
      else Fac[i+1] = ((i+1)*Fac[i])%MOD;
    }
  }
};

ll n,m,v,p;
vl a;
vl s;

bool check(int X){
  if(X <= p-1) return true;
  if(a[p-1] - a[X] > m) return false;

  // 票の受け皿の数
  ll num = n*m + (X-p+1)*a[X] - (s[X] - s[p-1]);
  return num >= m*v;
}


int main(){
  cin >> n >> m >> v >> p;
  a.resize(n);

  rep(i,n) cin >> a[i];

  sort(all(a));
  reverse(all(a));

  s.resize(n+1);
  rep(i,n) s[i+1] = s[i] + a[i];

  int ok = 0, ng = n;
  while (abs(ng-ok)>1){
    int mid = (ok+ng)/2;
    if(check(mid)) ok = mid;
    else ng = mid;
  }
  cout << ok+1 << endl;
}

Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {

    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();

        int ans = 0;
        if(a >= b && a >= c){
            ans = a * 10 + b + c;
        } else if (b >= c){
            ans = b * 10 + a + c;
        } else {
            ans = c * 10 + a + b;
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 25172
#include<iostream>
#include <algorithm>
using namespace std;
int main()
{
    int N;
    cin >> N;
    double v[N];
    for(int i = 0; i < N; i++) cin >> v[i];
    
    for(int i = N; i > 1; i--) {
      sort(v, v+i, greater<int>() );
      v[i-2] = (v[i-2]+v[i-1])/2;
    }
  
    cout << v[0] << endl;
}


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

using namespace std;

#define int long long
#define pb push_back
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define REP(i, n) FOR(i, 0, n)

vector<bool> isprime;

void sieve (int max) {
  if(max+1 > isprime.size()) {
    isprime.resize(max+1, true);
  }
  isprime[0] = false;
  isprime[1] = false;

  for(int i=2;i*i<=max;i++) {
    if(isprime[i]) {
      for(int j=2;i*j<=max;j++) {
        isprime[i*j] = false;
      }
    }
  }
}

signed main () {
  cin.tie(0);
  cout << setprecision(10);

  const int MAX = 100002;

  sieve(MAX);

  int q; cin >> q;

  int s = 0;
  vector<int> sum(MAX);
  
  REP(i, MAX) {
    if(isprime[i] && isprime[(i+1)/2]) {
      s++;
    }
    sum[i] = s;
  }

  int l, r;
  REP(i, q) {
    cin >> l >> r;

    cout << sum[r] - sum[l-1] << endl;
    
  }

  /*
  REP(i, r+1) {
    cout << sum[i] << endl;
  }

  REP(i, r+1) {
    cout << isprime[i] << endl;
  }
  */
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1e9 + 7;
const ll INF = LLONG_MAX;
const ll MINF = LLONG_MIN;
const int INT_INF = INT_MAX;

int main()
{
    int a, b;
    cin >> a >> b;
    int i = 0;
    int num = 1;
    while (num < b)
    {
        num--;
        num += a;
        i++;
    }
    cout << i << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#define MAX 10000

int isPrime(int);

int main(){
  int s, n, A[MAX], count = 0, i;

  scanf("%d",&n);

  for(s = 0; s < n; s++){
    scanf("%d",&A[s]);
    if(isPrime(A[s]))
      count++;
  }

  printf("%d\n",count);

  return 0;
}

int isPrime(int x){
  int i;
  if(x == 2)
    return 1;

  if(x < 2 || x % 2 == 0)
    return 0;

  i = 3;
  while(i * i <= x){
    if(x % i == 0)
      return 0;
    i = i + 2;
  }
  return 1;
}


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


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

    int cnt=0;
    for(int i=1;i<n-1;i++)
    {
        if(a[i] != max(a[i],max(a[i-1],a[i+1])) && a[i]!=min(a[i],min(a[i-1],a[i+1])))
            cnt++;//cout<<a[i]<<endl;
    }
    cout<<cnt;
}



Measured memory_bytes: 256
#include <bits//stdc++.h>
using namespace std;
#define int long long
#define rep(i,n,k) for(int i=n;i<k;i++)
#define P make_pair
#define F first
#define S second
#define M LLONG_MAX
signed main(void){
    int n,m,ans,p,q,c;
    ans=LLONG_MAX;
    string s1,s2;
    vector<int> v;
    cin>>n;
    int a[n];
    m=0;
    rep(i,0,n){
        cin>>a[i];
        m+=a[i];
    }
    p=0;
    rep(i,1,n){
        p+=a[i-1];
        m-=a[i-1];
        ans=min(ans,max(p-m,m-p));
    }
    cout<<ans<<endl;
    
}


Measured memory_bytes: 1792
from sys import stdin

def main():
    K, S = map(int, stdin.readline().rstrip().split())
    ans=0
    for X in range(K+1):
      for Y in range(K+1):
        Z = S - X -Y
        if Z >= 0 and Z <= K:
          ans +=1
        
    print(ans)

input = lambda: stdin.readline()
main()


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

typedef long long ll;
const int mod = 1e9 + 7;

ll N;
vector<ll> A;

int main() {
    cin >> N;
    A.resize(N);

    rep(i, N) cin >> A[i];

    map<ll, ll> mp;
    rep(i, N) mp[A[i]]++;

    // カードを 0 ~ 2枚にする
    ll second_card = 0;
    for (auto it : mp) {
        if (it.second > 0 && it.second % 2 == 0) {
            mp[it.first] = 2;
            second_card++;
        } 
        else if (it.second % 2 == 1) {
            mp[it.first] = 1;
        }
    }

    ll ans = mp.size();

    // マイナス調整
    if (second_card % 2 != 0) {
        ans--;
    }
    cout << ans << endl;
}

Measured memory_bytes: 7296
a = sorted(list(map( int, input().split())))

s = 0
if len(set(a)) == 1 :
  print(0)
elif a[0] == a[1]:
  print(a[2] -a[1])
else :
  if a[0]+1<a[1]:
    s +=(a[1]-a[0])//2
    a[0] = 2*s+a[0]
    if a[0] == a[1]:
      s+= a[2] -a[1]
    else :
      s+= a[2]-a[1] +2
  else :
      s+= a[2]-a[1] +2
  print(s)

Measured memory_bytes: 3064
from math import sqrt
def sieve(n):
    if n <= 4:
        return list(range(2, n))
    def _sieve_of_eratosthenes(n):
        limit = int(sqrt(n))+1
        table = [1] * n
        table[0] = table[1] = 0
        for i in range(2, limit):
            if table[i]:
                for j in range(i**2, n, i):
                    table[j] = 0
        return [i for i in range(2, n) if table[i]]
    return _sieve_of_eratosthenes(n)

q, *LR = map(int, open(0).read().split())
P = set(sieve(10**5))
d = {-1:0}
s = 0
for i in range(1, 10**5, 2):
    s += i in P and (i+1)//2 in P
    d[i] = s
for l, r in zip(LR[::2], LR[1::2]):
    print(d[r] - d[l-2])

Measured memory_bytes: 31536
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
using u64 = unsigned long long;
#define REP(i, n) for (int i = 0; (i64)(i) < (i64)(n); ++i)

#ifdef ENABLE_DEBUG
template <typename T>
void debug(T value) {
  cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  cerr << value << ", ";
  debug(args...);
}
#define DEBUG(...)                              \
  do {                                          \
    cerr << " \033[33m (L" << __LINE__ << ") "; \
    cerr << #__VA_ARGS__ << ":\033[0m ";        \
    debug(__VA_ARGS__);                         \
    cerr << endl;                               \
  } while (0)
#else
#define debug(...)
#define DEBUG(...)
#endif

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N, A;
  cin >> N >> A;
  vector<int> X(N);
  for (auto& x : X) cin >> x;
  sort(X.begin(), X.end());
  vector<int> cum(N + 1);
  for (int i = N - 1; i >= 0; --i) {
    cum[i] = cum[i + 1] + X[i];
  }
  map<tuple<int, int, int>, i64> memo;
  auto dfs = [&](auto rec, int i, int num, int acc) -> i64 {
    i64 res = 0;
    if (i >= N) return res;
    if (acc > N * A) return res;
    tuple<int, int, int> key = {i, num, acc};
    auto it = memo.find(key);
    if (it != memo.end()) {
      return it->second;
    }

    res += rec(rec, i + 1, num, acc);
    if (acc + X[i] == (num + 1) * A) {
      res++;
    }
    res += rec(rec, i + 1, num + 1, acc + X[i]);
    memo[key] = res;
    return res;
  };
  i64 ans = dfs(dfs, 0, 0, 0);
  cout << ans << '\n';
}

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

double dp[3000][3000];
double l[3000];
int mod = pow(10,9) +7;
deque<vector<int>> d;

int main() {
  string s,t; 
  cin >> s >> t;
  int flg = 0;
  if (s.size() +1 == t.size()){
    for(int i = 0;i<s.size();i++){
      if(s[i] != t[i]){
        flg = 1;
        break;
      }
    }
  }else{
    flg = 1;
    
  }
  if (flg == 0){
    cout << "Yes";
  }else{
    cout << "No";
  }
  
}


Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <math.h>
#include <limits>
#include <stdio.h>

template <typename T>
void vc(T t) {
    std::cout << t << " ";
}

template<typename T, typename... Args>
void vc(T t, Args... args) {
// recursive variadic function
    std::cout << t << " ";
    vc(args...) ;
}

const int N = 100000;

int dp[3001][3001];
double mp[3001][3001 * 2];
void once() {
  int n;
  std::cin >> n;
  std::vector<double> vd(n + 1);
  for (int i = 1; i <= n; ++i) {
    std::cin >> vd[i];
  }
  mp[1][n + 1] = vd[1];
  mp[1][n - 1] = 1 - vd[1];
  for (int i = 3; i <= n; i += 2) {
    double hh = vd[i] * vd[i - 1];
    double tt = (1 - vd[i]) * (1 - vd[i - 1]);
    double ht = 1.0 - hh - tt;
    // vc("- ", hh, tt, ht, hh + tt + ht, "\n");
    mp[i][n - i] = mp[i - 2][n + 2 - i] * tt;
    mp[i][n + i] = mp[i - 2][n + i - 2] * hh;
    for (int j = 2 - i; j <= i - 2; j += 2) {
      mp[i][n + j] += mp[i - 2][n + j] * ht;
      mp[i][n + j] += mp[i - 2][n + j + 2] * tt;
      mp[i][n + j] += mp[i - 2][n + j - 2] * hh;
    }
    // for (auto i : mp) {
    //   vc("+ ", mp[i.first], i.first.first, i.first.second, "\n");
    // }
  }
  double ans = 0;
  for (auto i = 0; i <=n; ++i) {
    ans += mp[n][i + n];
  }
  // std::cout << ans << std::endl;
  printf("%.10lf\n", ans);
}

int
main() {
  int n = 1;
  std::ios::sync_with_stdio(false);
  // std::cin >> n;
  while (n--) {
    once();
  }
}

Measured memory_bytes: 139648
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define M1 					1000000007
#define M2 					998244353
#define ll 					long long int
#define pll 				pair<ll,ll>
#define mll 				map<ll,ll>
#define F 					first
#define S 					second
#define PB 					push_back
#define mp 					make_pair
#define lb 					lower_bound
#define ub 					upper_bound
#define V(a) 				vector<a>
#define endl 				'\n'
#define test(t) 			while(t--)
#define PI 					acos(-1.0)
#define rep(i,a,b) 			for(ll i=a;i<b;i++)
#define repp(i,b,a) 		for(ll i=b-1;i>=a;i--)
#define clr(ar, val)		memset(ar, val, sizeof(ar))
#define setbits(x) 			__builtin_popcountll(x)
#define zrobits(x) 			__builtin_ctzll(x)
#define ps(y) 				fixed << setprecision(y)
#define all(x) 				begin(x),end(x)
#define allr(x) 			rbegin(x),rend(x)
const int inf= 				0x3f3f3f3f;
const ll INF= 				0x3f3f3f3f3f3f3f3f;
const int dx[4]= 			{ 0, -1, 0, 1 };
const int dy[4]= 			{ -1, 0, 1, 0 };

unsigned  int  randInt (){ 
    static  unsigned  int  tx  =  123456789 ,  ty = 362436069 ,  tz = 521288629 ,  tw = 88675123 ; 
    unsigned  int  tt  =  ( tx ^ ( tx << 11 )); 
    tx  =  ty ;  ty  =  tz ;  tz  =  tw ; 
    return  (  tw = ( tw^ ( tw >> 19 )) ^ ( tt ^ ( tt >> 8 ))  ); 
}

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template<typename T>
#define o_set(T) tree<T, null_type,less<T>, rb_tree_tag,tree_order_statistics_node_update>
//member functions :
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set

ll floor_div(ll a, ll b) {
	return a / b - (((a ^ b) < 0) and a % b);
}
ll ceil_div(ll a, ll b){
    return a / b + (((a ^ b) >= 0) and a % b);
}

inline void INP()
{
	#ifndef ONLINE_JUDGE
	    freopen("input.txt","r",stdin);   
	    freopen("output.txt","w",stdout);
	#endif 
}


void solve()
{
    string s;
    cin >> s;
    // rep(i,0,2019){
    //     dp[0][i] = dp[1][i] = dp[2][i] = 0;
    // }
    ll ans = 0;
    ll dp[2019];
    clr(dp,0);
    dp[s[0] - '0'] = 1;
    rep(i,1,s.size()){
        int d = s[i] - '0';   
        ll tdp[2019];
        clr(tdp,0);
        tdp[d] = 1;
        rep(j,0,2019){
            if (dp[j] > 0){
                // cout << i << " " << j << endl;
                ll rem = (10*j + d)%2019;
                if (rem == 0) ans+=dp[j];
                tdp[rem]+=dp[j];
            }
        }
        rep(i,0,2019){
            dp[i] = tdp[i];
        }   
    }
    cout << ans;

}

int32_t main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;
    // cin>>t;
    test(t){
        solve();
    }
    return 0;
}

Measured memory_bytes: 3780
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <queue>
#include <map>
#include <stack>
#include <bitset>
#include <numeric> //lcm
#include <iomanip> //double精度 setprecision

using namespace std;

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = n-1; i >= 0; --i)
#define rep1(i,n) for(int i = 1; i <= (n); ++i)
#define rrep1(i,n) for(int i = (n); i >= 1; --i)
#define all(vec) (vec).begin(),(vec).end()

#define debug(vec) for(auto v : vec) cerr << v << " "; cerr << endl;
#define debug2D(vec2D) for(auto vec : vec2D) { for (auto v : vec) cerr << v << " "; cerr << endl; } 
#define debugP(vec) for(auto v : vec) cerr << "(" << v.first << "," << v.second << ") "; cerr << endl;
#define debug2DP(vec2D) for(auto vec : vec2D) { for (auto v : vec) cerr << "(" << v.first << "," << v.second << ") "; cerr << endl; } 

typedef long long ll;

constexpr ll INF = 1000000000; //10^10
//const ll MOD = 998244353;
constexpr ll MOD = 1000000007;

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

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

	int n,m; cin >> n >> m;

	vector<int> p(m), y(m);
	rep(i,m) { 
	  cin >> p[i] >> y[i]; p[i]--;
	}

	map<int, pair<int,int>> mp;
	vector<int> cnt(n+1,1);

	rep(i, m) {
		mp[y[i]] = { p[i], i};
	}

	vector<ll> ans(m);
	for (auto& ypi : mp) {
	  ans[ypi.second.second] = pow(10,6)*(ypi.second.first+1LL) + cnt[ypi.second.first];
		++cnt[ypi.second.first];
	}

	for(auto& a : ans) cout << setfill('0') << setw(12) << a << endl;
}

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

using namespace std;

// Common DS shorteners
using ll = long long; using ull = unsigned long long;
using pii = pair<int, int>; using pll = pair<ll, ll>;
template <typename T> using vec = vector<T>;
template <typename K, typename V> using mp = unordered_map<K, V>;
template <typename K> using us = unordered_set<K>;
using vi = vec<int>; using vl = vec<ll>; using vpi = vec<pii>; using vpl = vec<pll>;
// Shorthand Macros
#define INF 0x3f3f3f3f
#define LLINF 0x3f3f3f3f3f3f3f3f
#define mpr make_pair
#define pb push_back
// Shorthand Functions
template<typename T> inline void maxa(T& st, T v) { st = max(st, v); }
template<typename T> inline void mina(T& st, T v) { st = min(st, v); }
// Out operators and printing for arrays and vectors
template <typename T> ostream& operator<<(ostream& out,vector<T> iter){out<<"[";for(auto t:iter){out<<t<<", ";}out<<"]";return out;}
template <typename T> void printDebug(T *arr,int sz){cout<<"[";for(int i=0;i<sz;i++){cout<<arr[i]<<", "; } cout<<"]\n";}
template <typename T> void printArray(T *arr,int sz){for(int i=0;i<sz;i++){cout<<arr[i]<<" "; } cout<<"\n";}
#define OUT_OPERATOR(type, propa, propb) ostream& operator<<(ostream& out,type obj){out<<"("<<#propa<<"="<<obj. propa<<", "<<#propb<<"="<<obj. propb<<")";return out;}
// I/O Operations
inline void scan(){}
template<typename F, typename... R> inline void scan(F &f,R&... r){cin>>f;scan(r...);}
inline void println(){cout<<"\n";}
template<typename F, typename... R> inline void println(F f,R... r){cout<<f<<" ";println(r...);}
inline void print(){}
template<typename F, typename... R> inline void print(F f,R... r){cout<<f;print(r...);}
// Debugging
int di_; string dnms_, co_ = ",";
void debug_(){cout<<endl;}
template<typename F, typename... R>
void debug_(F f,R... r){int bc=0;while (bc != 0 || dnms_[di_] != ','){if (dnms_[di_] == '(') {bc++;}else if (dnms_[di_] == ')') {bc--;}cout << dnms_[di_++];}di_++;cout << ": " << f << ",";debug_(r...);}
#define debug(...) do{dnms_=#__VA_ARGS__+co_,di_=0,debug_(__VA_ARGS__);}while(0)

const int MN = 2e5 + 1;
int n, q, ba, bb,
    sums[MN];
vi g[MN];

void dfs(int cur, int par, int curSum) {
    sums[cur] += curSum;
    for (int adj : g[cur])
        if (adj ^ par)
            dfs(adj, cur, sums[cur]);
}

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

    scan(n, q);

    for (int i = 1; i < n; i++) {
        scan(ba, bb);
        g[ba].pb(bb);
        g[bb].pb(ba);
    }

    for (int i = 0; i < q; i++) {
        scan(ba, bb);
        sums[ba] += bb;
    }

    dfs(1, -1, 0);

    printArray(sums + 1, n);

    return 0;
}


Measured memory_bytes: 23552
def sub753(K, lst):
    if K == 1:
        return ['3', '5', '7']
    ans = [pre + suf for suf in sub753(K - 1, lst) for pre in '357']
    lst.extend(ans)
    return ans


N = int(input())

lst = list()
sub753(10, lst)

cnt = 0
for num in lst:
    if '3' in num and '5' in num and '7' in num and int(num) <= N:
        cnt += 1
print(cnt)


Measured memory_bytes: 9884
s=input()


i=0
c=0
flag=0
while True:
	if i>len(s)-2: break
	if s[i]=="A":
		flag+=1
		i+=1
	elif flag and s[i:i+2]=="BC":
		c+=flag
		i+=2
	else:
		flag=0
		i+=1

print(c)

Measured memory_bytes: 3500
//
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
//
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

// solution 
use std::cmp;
#[allow(unused_mut)]
#[allow(non_snake_case)]
fn main() {
    input!{
        A: usize,
        B: usize,
    }

    if A > B {
        println!("{}", A + cmp::max(A-1, B));
    } else {
        println!("{}", B + cmp::max(A, B-1));
    }
}


Measured memory_bytes: 4352
using System;

class Program
{
    static void Main(string[] args)
    {
        switch (Console.ReadLine())
        {
            case "1":
                Console.WriteLine("Hello World");
                return;
            case "2":
                Console.WriteLine(
                    int.Parse(Console.ReadLine()) +
                    int.Parse(Console.ReadLine()));
                return;
        }
    }
}


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


int dp[100];

//最大公約数
int gcd(int x, int y){
  if(x % y == 0) return 1;
  return gcd(y, x % y);
}
//最小公倍数
int lcm(int x, int y){
  return x * y / gcd(x, y);
}
//フィボナッチ数列
//配列dpを-1で初期化する
int fib(int n){
  if(n == 0 || n == 1) return dp[n] = 1;
  if(dp[n] != -1) return dp[n];
  return dp[n] = fib(n - 1) + fib(n - 2);
}
//階乗計算(factorial)
int fact(int n){
  if(n = 1) return 1;
  return n * fact(n - 1);
}
//累乗計算(Exponentiation)
//x**y
ll expo(int x, int y){
  ll ans = 1;
  rep(i, y){
    ans *= x;
  }
  return ans;
}
//桁数
int keta(ll x){
  if(x == 0) return 1;
  int res = 0;
  while(x){
    x /= 10;
    res++;
  }
  return res;
}


int main(){
  int n, l;
  cin >> n >> l;
  int ans = 0;

  rep(i, n) ans += l + (i+1) - 1;

  if(l <= 0 && l+n-1 >= 0) cout << ans << endl;
  else if(l > 0) cout << (ans - l) << endl;
  else if(l+n-1 < 0) cout << (ans - (l+n-1)) << endl;
}

/*





















*/


Measured memory_bytes: 256
//A.cpp
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <math.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
const ll mod=1e9+7;

int main(){
  ll a,b,k;
  cin >> a >> b >> k;
  if(a >= k) a -= k;
  else{
    k -= a;
    a = 0;
    if(b >= k) b -= k;
    else b = 0;
  }
  printf("%lld %lld\n", a,b);
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<tuple>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-15
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	int N;
	int A[100001];
	int count[100001]={};
	int amari=0;
	scan(N);
	rep(i,N){
		scan(A[i]);
		count[A[i]]++;
	}
	rep1(i,100000){
		amari+=max(0,count[i]-1);
	}
	prin(N-amari-amari%2);
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e18;
int mod = 1e9+7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
signed main() {
    int N;
    cin >> N;
    vector<int>A(N);
    int res = 0;
    for(int i = 0; i < N; i++) {
        cin >> A[i];
        A[i] %= mod;
        res += A[i];
        res %= mod;
    }
    int ans = 0;
    for(int i = 0; i < N; i++) {
        res = (res+mod-A[i])%mod;
        ans += A[i]*res%mod;
        ans %= mod;
    }
    cout << ans << endl;
}

Measured memory_bytes: 4776
package main

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

func main() {
	L := readI()
	fmt.Println(float64(L*L*L) / 27)
}

/*-----------Utils-----------*/

var sc = bufio.NewScanner(os.Stdin)

func init() {
	if len(os.Args) >= 2 {
		if os.Args[1] == "debug" {
			debug()
		}
	}
	const maxBuf = 200100
	var buf []byte = make([]byte, maxBuf)
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBuf)
}

func debug() {
	testFile, err := os.Open("./test/sample-1.in")
	if err != nil {
		fmt.Fprintln(os.Stderr, "Error : There is no testfile.")
		os.Exit(1)
	}
	sc = bufio.NewScanner(testFile)
}

func readS() string {
	sc.Scan()
	return sc.Text()
}

func readSs(a int) []string {
	b := make([]string, a)
	for i := 0; i < a; i++ {
		b[i] = readS()
	}
	return b
}

func readI() int {
	sc.Scan()
	r, _ := strconv.Atoi(sc.Text())
	return r
}

func readIs(a int) []int {
	b := make([]int, a)
	for i := 0; i < a; i++ {
		b[i] = readI()
	}
	return b
}

func readF() float64 {
	sc.Scan()
	r, _ := strconv.ParseFloat(sc.Text(), 64)
	return r
}

func readFs(a int) []float64 {
	b := make([]float64, a)
	for i := 0; i < a; i++ {
		b[i] = readF()
	}
	return b
}


Measured memory_bytes: 1780