akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import java.io.*;
import java.lang.*;
import java.math.*;
public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
        String s = bf.readLine();
        int n = s.length();
        Set<String> abc = new HashSet<String>();
        abc.add("abc");
        abc.add("acb");
        abc.add("bac");
        abc.add("bca");
        abc.add("cab");
        abc.add("cba");
        int diff = 0;
        for(int i=0; i<n-1; i++) {
          if(s.charAt(i) != s.charAt(i+1)) diff++;
        }
        if(n <= 2) {
          if(s.charAt(0) == s.charAt(1)) out.println(1);
          else out.println(2);
        }
        else if(abc.contains(s)) out.println("3");
        else if(diff == 0){
          out.println("1");

        }
        else {
        int mod = 998244353;
        long[][][] dp = new long[n][3][3]; // 0, 1, 2 as last remainder;
        long[][][] dp_no_dpl = new long[n][3][3]; // a, b, c as last digit; 0, 1, 2 as last remainder
        long ans = 1;
        for(int i=0; i<n-1; i++) {
          if(s.charAt(i) == s.charAt(i+1)) ans = 0;
        }
        int sum = 0;
        for(int i=0; i<n; i++) {
          sum += (s.charAt(i)-'a');
          sum %= 3;
        }
        dp[0][0][0] = 1;
        dp[0][1][1] = 1;
        dp[0][2][2] = 1;
        dp_no_dpl[0][0][0] = 1;
        dp_no_dpl[0][1][1] = 1;
        dp_no_dpl[0][2][2] = 1;
        for(int i=1; i<n; i++) {
          for(int j=0; j<3; j++) {
            dp_no_dpl[i][0][j] += dp_no_dpl[i-1][1][(j+3-0)%3];
            dp_no_dpl[i][0][j] += dp_no_dpl[i-1][2][(j+3-0)%3];
            dp_no_dpl[i][1][j] += dp_no_dpl[i-1][0][(j+3-1)%3];
            dp_no_dpl[i][1][j] += dp_no_dpl[i-1][2][(j+3-1)%3];
            dp_no_dpl[i][2][j] += dp_no_dpl[i-1][0][(j+3-2)%3];
            dp_no_dpl[i][2][j] += dp_no_dpl[i-1][1][(j+3-2)%3];

            for(int k=0; k<3; k++) dp_no_dpl[i][k][j] %= mod;
          }
        }

        ans += exp(3, n-1, mod) + mod;
        ans += 1L*3*mod - dp_no_dpl[n-1][0][sum] - dp_no_dpl[n-1][1][sum] - dp_no_dpl[n-1][2][sum];
        ans %= mod;
        out.println(ans);
        }
        //
        // int n = Integer.parseInt(bf.readLine());
        // StringTokenizer st = new StringTokenizer(bf.readLine());
        // int[] a = new int[n];
        // for(int i=0; i<n; i++) a[i] =  Integer.parseInt(st.nextToken());

        out.close(); System.exit(0);
    }

    public static int exp(int base, int e, int mod) {
      if(e == 0) return 1;
      if(e == 1) return base;
      int val = exp(base, e/2, mod);
      int ans = (int)(1L*val*val % mod);
      if(e % 2 == 1)
        ans = (int)(1L*ans*base % mod);
      return ans;
    }
}


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

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }

  function<bool(int)> check = [&] (int b) -> bool {
    int num = 0;
    for (int i = 0; i < n; i++) {
      if (a[i] <= b + i + 1) num++;
    }
    return (num <= n / 2);
  };

  int l = - ((int) 1e9 + 7), r = (int) 1e9 + 7;
  while (r - l > 1) {
    int mid = (l + r) / 2;
    if (check(mid)) l = mid;
    else r = mid;
  }

  long long res = 0;
  // cerr << r << "\n";
  for (int i = 0; i < n; i++) {
    res += abs(a[i] - (r + i + 1));
  }
  cout << res << "\n";
}

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

l = [0] + l
diff = [0]*(n+1)

zeros = []
ans = []
for i in range(1,n+1):
    if l[i] > i:
        print("-1")
        exit(0)
    else:
        diff[i] = i-l[i]
        if diff[i] == 0:
            zeros.append(i)
for i in range(1,n+1):
    max0 = zeros.pop()
    for j in range(max0+1,n+1):
        if diff[j] == -1:
            continue
        diff[j] -= 1
        if diff[j] == 0:
            zeros.append(j)
    ans.append(l[max0])
    
for item in ans[::-1]:
    print(item)




Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"
const int dx[] = { -1 , -1 , -1 , 0 , 0 , 0 , 1 , 1 , 1 };
const int dy[] = { -1 , 0 , 1 , -1 , 0 , 1 , -1 , 0 , 1 };
#define N 8010000
#define TC int t;cin>>t;for(int T=1;T<=t;T++)
#define mod 1000000007
#define PI acos(-1)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
void AIA() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); }
//cout<<fixed<<setprecision(20);
// freopen("stand.in","r",stdin);
// freopen("stand.out","w",stdout);

/*
 _____________              __                ___        ___       ___________________________     ____        ____
|             |            /\ \              |   |      |   |     |                           |    \   \      /   /
|   __________|           / /\ \             |   |      |   |     |      _____      _____     |     \   \    /   /
|  |                     / /  \ \            |   |      |   |     |     |     |    |     |    |      \   \  /   /
|  |                    / /    \ \           |   |      |   |     |     |     |    |     |    |       \   \/   /
|  |______             / /      \ \          |   |______|   |     |     |     |    |     |    |        \      /
|         |           / /        \ \         |              |     |     |     |    |     |    |         \    /
|   ______|          / /          \ \        |    ______    |     |     |     |    |     |    |          |  |
|  |                / /============\ \       |   |      |   |     |     |     |    |     |    |          |  |
|  |               / /==============\ \      |   |      |   |     |     |     |    |     |    |          |  |
|  |              / /                \ \     |   |      |   |     |     |     |    |     |    |          |  |
|  |             / /                  \ \    |   |      |   |     |     |     |    |     |    |          |  |
|__|            /_/                    \_\   |___|      |___|     |_____|     |____|     |____|          |__|

										  <<<<<<<<<<< NEVER GIVE UP !! >>>>>>>>>>>
										<<<<<<<< YOU CAN DO IT IF YOU WANT !! >>>>>>>>
										 <<<<<<<<< BELIEVE IN YOURSELF !! >>>>>>>>>

*/
int main()
{
	//cout << fixed << setprecision(9);
	//freopen("stand.in","r",stdin);
	//freopen("stand.out","w",stdout);
	AIA();
    int t;cin>>t;
        if(t%10 == 2 || t%10 == 4 || t%10 == 5 || t%10==7 || t%10 == 9)
            cout<<"hon";

        else if(t%10==0 || t%10==1 || t%10==6 || t%10==8)
            cout<<"pon";

        else cout<<"bon";

	return 0;
}


Measured memory_bytes: 3652
import java.util.Scanner;

class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int a, b, c;
        char op;
        while(true){
            a = scan.nextInt();
            op = scan.next().charAt(0);
            b = scan.nextInt();
            if(op == '?'){ break; }
            else if(op == '+'){ c = a + b; }
            else if(op == '-'){ c = a - b; }
            else if(op == '*'){ c = a * b; }
            else{ c = a / b; }
            System.out.println(c);
        }
    }
}


Measured memory_bytes: 26172
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    a, b = LI()
    if a <= 5:
        print(0)
    elif 6 <= a <= 12:
        print(b // 2)
    else:
        print(b)
    return

#B
def B():
    r, d, x = LI()
    for i in range(10):
        print(x * r - d)
        x = x * r - d
    return

#C
def C():
    n, m = LI()
    imo = [0 for i in range(n+1)]
    for _ in range(m):
        l, r = LI_()
        imo[l] += 1
        imo[r + 1] -= 1
    for i in range(1,n):
        imo[i] += imo[i - 1]
    ans = 0
    #print(imo)
    for i in imo:
        if i == m:
            ans += 1
    print(ans)
    return

#D
def D():
    n, m = LI()
    a = LI()
    bc = LIR(m)
    bc.sort(key=lambda x: x[1], reverse=True)
    a.sort()
    index = 0
    suma = 0
    for b, c in bc:
        if index + b >= n:
            if a[n - 1] <= c:
                suma += (n - index) * c
            else: 
                br = bisect_left(a, c)
                if br > index:
                    suma += (br - index) * c
                    index = br
                    break
                else:
                    break
            index = n
            break
        if a[index + b - 1] < c:
            suma += b * c
            index += b
        else:
            if a[index] < c:
                bl = bisect_left(a, c)
                suma += (bl - index) * c
                index = bl
            else:
                break
    suma += sum(a[index:])
    print(suma)

    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    D()


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

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n, m;
	cin >> n >> m;
	if (n % 500 > m)
		cout << "No";
	else
		cout << "Yes";
	return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <numeric>
#include <ctime>
#include <complex>
#include <bitset>
#include <random>
#include <stack>

using namespace std;

typedef long long ll;
typedef long double ld;

#define int ll
#define double ld
#define loop(i, n) for(int i = 0; i < (int)n; ++i)
#define loop1(i, n) for(int i = 1; i <= (int)n; ++i)
#define F first
#define S second
#define pb push_back
#define pi pair <int, int>
#define all(x) begin(x), end(x)
#define ti tuple <int, int, int>
#define Point Vect
#define mkt make_tuple
#define no {cout << -1; return;}

void solve() {
    int n; cin >> n;
    vector <tuple <string, int, int> > a(n);
    loop(i, n) {
        cin >> get<0>(a[i]) >> get<1>(a[i]);
        get<2>(a[i]) = i + 1;
    }
    sort(all(a), [](auto t1, auto t2) { return get<0>(t1) < get<0>(t2) || (get<0>(t1) == get<0>(t2) && get<1>(t1) > get<1>(t2)); });
    loop(i, n)
        cout << get<2>(a[i]) << "\n";
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //int t; cin >> t; loop(i, t)
    solve();
    return 0;
}

Measured memory_bytes: 3604
#include<iostream>
#include<algorithm>
#include<vector>
#include<cstdio>
#include<cmath>
using namespace std;

#define ll long long int
#define ld long long double
#define reps(i,f,n) for(int i=f;i<n;i++)
#define rep(i,n) reps(i,0,n)
#define m1 cout<<"move1"<<endl
#define m2 cout<<"move2"<<endl
#define m3 cout<<"move3"<<endl
#define m4 cout<<"move4"<<endl

int main(){
  int flag = 1;
  int a,b,c;
  int t=0;
  int c_ans;
  int counter =0;

  cin>>a>>b>>c;
  c_ans = c;

  while(1){
    counter++;
    if(counter >= 100000)
      {
	cout<<-1<<endl;
	break;
      }
    if( c+60*t - a <= 0 && flag == 1){
      //m1;
      cout<< c_ans + 60*t<<endl;
      break;
    }
    //else if(c + 60 * t - a <=0 && flag == 1){
    //t++;
    //flag = 0;
    //}
    else if(c + 60 * t - a >= 0 && flag == 1){
      //m2;
      c-=a;
      flag = 0;
    }
    else if(c + 60 * t - b == 0 && flag == 0){
      //m3;
      cout<<c_ans + 60 * t <<endl;
      break;
    }
    else if(c + 60 * t - b < 0 && flag == 0){
      if( 60 % ( a + b ) == 0){
	cout<<-1<<endl;
	break;
      }
      else{
	t++;
      flag = 1;
      c-=b;
      // m4;
      }
    }
    else {
      c -= b;
      flag = 1;
    }
  }

  return 0;
}




      
      
      
      

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

int N;

void solve(){
    cin >> N;
    vector<int> A(N);
    vector<int> B(N);

    for(int i=0; i<N; i++){
        cin >> A[i];
        B[A[i]-1] = i+1;
    }
    //sort(A.begin(), A.end());
    for(int i=0; i<N-1; i++){
        cout << B[i] << ' ';
    }
    cout << B[N-1] << endl;
}
int main(){
    solve();
}

Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fi first
#define se second
#define pb push_back
#define pr pair<int,int>
#define PI 3.1415926535897932384626
#define mod 1000000007
#define fo(i,n) for(i=0;i<n;i++)
#define endl "\n"
#define mset(m,v) memset(m,v,sizeof(m))
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
typedef vector<int>	vi;
#define FAST_IO  ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)

void solve()
{
	string s;
	cin >> s;
	if(s[s.size()-1]=='s'){
	    cout << s << "es" << endl;
	}
	else{
	    cout << s << "s" << endl;
	}
}

int32_t main()
{
	FAST_IO;
	int t=1;//cin>>t;
	for(int i=1;i<=t;i++){	solve();}
	return 0;
}

Measured memory_bytes: 3660
#include <iostream>

using namespace std;

int main(void) {
    string s, left, right;
    cin >> s;
    left = s.substr(0, (s.length() - 1) / 2);
    right = s.substr((s.length() + 3) / 2 - 1);
    bool s_ok = true, l_ok = true, r_ok = true;
    for (int i = 0; i < s.length(); ++i) {
        if (s[i] == s[s.length() - 1 - i]) continue;
        else s_ok = false;
    }
    for (int i = 0; i < left.length(); ++i) {
        if (left[i] == left[left.length() - 1 - i]) continue;
        else l_ok = false;
    }
    for (int i = 0; i < right.length(); ++i) {
        if (right[i] == right[right.length() - 1 - i]) continue;
        else r_ok = false;
    }
    cout << ((s_ok && l_ok && r_ok) ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#define MIN(a,b) (((a)>(b))?(b):(a))
#define MAX(a,b) (((a)<(b))?(b):(a))
using namespace std;

typedef pair<int,int> pii;

int main(void){
	int n,m,a,b;
	int l[200000],r[200000];
	std::vector<pii> v;
	cin>>n>>m;
	for(int i=0;i<n;i++)l[i]=r[i]=i;
	for(int i=0;i<m;i++){
		cin>>a>>b;
		v.push_back(make_pair(a,b-1));
	}
	std::sort(v.begin(),v.end());
	for(int i=0;i<v.size();i++){
		int lane=v[i].second;
		l[lane]=MIN(l[lane+1],l[lane]);
		r[lane]=MAX(r[lane+1],r[lane]);
		l[lane+1]=MIN(l[lane],l[lane+1]);
		r[lane+1]=MAX(r[lane],r[lane+1]);
		// cout<<"---"<<i<<"---"<<endl;
		// for(int j=0;j<n;j++){
			// cout<<l[j]<<" "<<r[j]<<endl;
		// }
	}

	for(int i=0;i<n;i++){
		if(i!=n-1)cout<<r[i]-l[i]+1<<" ";
		else cout<<r[i]-l[i]+1<<endl;
	}

	return 0;
}

Measured memory_bytes: 5400
/*#include<iostream>
int main(){
int a,b;
int x,y,z,count;
while(true){
std::cin>>a>>b;
count=0;
if(a==0&&b==0)break;
x=1;y=0;z=0;
for(int i=1;i<=a-2;i++){
for(int j=i+1;j<=a-1;j++){
for(int k=j+1;k<=a;k++){
if(i+j+k==b){
count++;
break;
}
}
}
}
std::cout<<count<<std::endl;
    }

    return 0;

}*/
#include<iostream>
int main(){
    int a,count=0,ans=0;
    std::cin>>a;
    for(int i=1;i<=a;i+=2){
        count=0;
        for(int j=1;j<=i;j++){
            if(i%j==0)count++;
            if(count>8)break;
        }
//        std::cout<<"i:"<<i<<" count:"<<count<<std::endl;
        if(count==8)ans++;
        
    }
    std::cout<<ans<<std::endl;
    return 0;
}


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

int main() {
    int N, M;
    cin >> N >> M;
    vector<string> A(N), B(N);
    rep(i,N) cin >> A.at(i);
    rep(i,M) cin >> B.at(i);
    rep(i,N-M+1) {
        rep(j,N-M+1) {
            bool include = true;
            rep(k,M) {
                rep(l,M) {
                    if (B.at(k).at(l) != A.at(i + k).at(j + l)) {
                        include = false;
                    }
                }
            }
            if (include) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
}


Measured memory_bytes: 3604
#include <cmath>
#include <queue>
#include <cstdio>
#include <vector>
#include <cstring>
#include <iostream>
#include <algorithm>
#define il inline 
#define re register
#define LL long long
using namespace std;
const int mod = 1e9 + 7;
const int INF = (1 << 30);
const int maxn = 2e5 + 50;
LL read() {
    LL res = 0, f = 1; char ch = ' ';
    while (!isdigit(ch)) { ch = getchar(); if (ch == '-') f = -1; } 
    while (isdigit(ch)) res = (res << 3) + (res << 1) + ch - '0', ch = getchar();
    return res * f;
}

int n, a[maxn], ans;
bool Check(int k) {
	for (re int i = 0; i < n - 1; ++i) {
		if ((a[n + i] > k && a[n + i + 1] > k) || (a[n - i] > k && a[n - i - 1] > k)) return 0;
		if ((a[n + i] <= k && a[n + i + 1] <= k) || (a[n - i] <= k && a[n - i - 1] <= k)) return 1;
	}
	return a[1] <= k;
}
int main() {
	n = read();
	for (re int i = 1; i < 2 * n; ++i) a[i] = read();
	int l = 1, r = 2 * n - 1;
	while (l <= r) {
		int mid = (l + r >> 1);
		if (Check(mid)) r = mid - 1, ans = mid;
		else l = mid + 1;
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if(a <= b && b <= c)cout << a << ' ' << b << ' ' << c << endl;
	else if(a <= c && c <= b)cout << a << ' ' << c << ' ' << b << endl;
	else if(b <= a && a <= c)cout << b << ' ' << a << ' ' << c << endl;
	else if(b <= c && c <= a)cout << b << ' ' << c << ' ' << a << endl;
	else if(c <= a && a <= b)cout << c << ' ' << a << ' ' << b << endl;
	else if(c <= b && b <= a)cout << c << ' ' << b << ' ' << a << endl;
}


Measured memory_bytes: 3116
#include <bits/stdc++.h>
#define endl '\n'
#define int long long
#define lint long long
#define pii pair<int,int>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define SZ(v) ((int)v.size())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MINF(a) memset(a,0x3f,sizeof(a))
#define POW(n) (1LL<<(n))
#define POPCNT(n) (__builtin_popcount(n))
#define IN(i,a,b) (a <= i && i <= b)
using namespace std;
template <typename T> inline bool CHMIN(T& a,T b) { if(a>b) { a=b; return 1; } return 0; }
template <typename T> inline bool CHMAX(T& a,T b) { if(a<b) { a=b; return 1; } return 0; }
template <typename T> inline void SORT(T& a) { sort(ALL(a)); }
template <typename T> inline void REV(T& a) { reverse(ALL(a)); }
template <typename T> inline void UNI(T& a) { sort(ALL(a)); a.erase(unique(ALL(a)),a.end()); }
template <typename T> inline T LB(vector<T>& v, T a) { return *lower_bound(ALL(v),a); }
template <typename T> inline int LBP(vector<T>& v, T a) { return lower_bound(ALL(v),a) - v.begin(); }
template <typename T> inline T UB(vector<T>& v, T a) { return *upper_bound(ALL(v),a); }
template <typename T> inline int UBP(vector<T>& v, T a) { return upper_bound(ALL(v),a) - v.begin(); }
template <typename T1, typename T2> ostream& operator<< (ostream& os, const pair<T1,T2>& p) { os << p.first << " " << p.second; return os; }
template <typename T1, typename T2> istream& operator>> (istream& is, pair<T1,T2>& p) { is >> p.first >> p.second; return is; }
template <typename T> ostream& operator<< (ostream& os, const vector<T>& v) { REP(i,v.size()) { if (i) os << " "; os << v[i]; } return os; }
template <typename T> istream& operator>> (istream& is, vector<T>& v) { for(T& in : v) is >> in; return is; }
template <typename T = int> vector<T> make_v(size_t a) { return vector<T>(a); }
template <typename T, typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...)); }
template <typename T, typename V> typename enable_if<is_class<T>::value == 0>::type fill_v(T &t, const V &v) { t = v; }
template <typename T, typename V> typename enable_if<is_class<T>::value != 0>::type fill_v(T &t, const V &v) { for(auto &e : t) fill_v(e,v); }
const lint MOD = 1000000007;
const lint INF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-10;



void _main() {
    int N;
    cin >> N;
    cout << N / 2 - (N % 2 == 0) << endl;
}

signed main(signed argc, char **argv) {
    if (argc > 1) {
        if (strchr(argv[1], 'i')) freopen("input.txt", "r", stdin);
        if (strchr(argv[1], 'o')) freopen("output.txt", "w", stdout);
    }
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    _main();
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,m,n) for(int i=m;i<n;i++)
ll mod=1e9+7;

int main(){
  int a,b;
  cin>>a>>b;
  int c=b*10;
  int d=(b+1)*10;
  int ans=-1;
  for(int i=c;i<d;i++){
    if(i*2/25==a){
      ans=i;
      break;
    }
  }
  cout<<ans<<endl;
}

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

int main() {
	int n, length; string s;
	cin>>n>>s;
	length=s.length();
	
	for(int i=0;i<length;i++){
		if(int(s[i])+n>int('Z'))
		s[i]=char(int(s[i])+n-27+1);
		else s[i]=char(int(s[i])+n);
	}
	cout<<s;
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
int N, L;
cin >> N >> L;
string s[105];
for(int i = 0; i < N; i++){
  cin >>s[i];
}
sort(s,s+N);
for(int i = 0; i< N; i++){
  cout << s[i];
}
}

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

#define PI 3.14159265359
//2の累乗数かどうか
bool hantei(int N) {
	bool flag = false;
	while (1) {
		if (N % 2 == 0) N /= 2;
	}
	if (N == 1) flag = true;

	return flag;
}
vector<ll> divisor(ll n){
	vector<ll> res;//約数を格納する列
	for(ll i= 1;i*i <= n;i++){
		if(n % i == 0){
		   res.push_back(i);
		   if(i != n/i) res.push_back(n/i);
		 }
	}
	return res;
}
int main() {
	ll X;
	cin >> X;
	vector<ll> res = divisor(X);
	ll N = res.size();
	for (int i = 0; i < N; i++) {
		
		ll M = res[i];//Xの約数
		for (ll A = -500; A <= 500; A++) {
			ll B = A - M;
			if (A*A*A*A*A - B*B*B*B*B == X) {
				cout << A << " " << B << endl;
				break;
			}
		}
	}
}


Measured memory_bytes: 3632
#   ==========     //\\       //||     ||====//||
#       ||        //  \\        ||     ||   // ||
#       ||       //====\\       ||     ||  //  ||
#       ||      //      \\      ||     || //   ||
#   ========== //        \\  ========  ||//====|| 
#  code

# 1 -> 1,2 2,1 3,
# 2 -> 1,1
def solve():
    n = int(input())
    cnt = 0
    for i in range(1, n + 1):
        k = n // i
        if n % i:
            cnt += k
        else:
            cnt += max(0, k - 1)
    print(cnt)
    return

def main():
    t = 1
    # t = int(input())
    for _ in range(t):
        solve()

if __name__ == "__main__":
    main()

Measured memory_bytes: 9168
#![allow(unused_imports)]
#![allow(dead_code)]
use std::io::prelude::*;
use std::cmp::{max, min};

const MOD: i64 = 1e9 as i64 + 7; 

fn main(){
    let n: isize = read();
    let mut ans = 0;
    for i in 1..n+1{
        let mut t = i;
        let mut cnt = 0;
        while t > 0{
            t /= 10;
            cnt += 1;
        }
        if cnt % 2 == 1{
            ans += 1;
        }
    }
    println!("{}", ans);
}

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


Measured memory_bytes: 4352
package main

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

func main() {
	k := readI()
	acl := []rune("ACL")
	for i := 1; i < k; i++ {
		acl = append(acl, []rune("ACL")...)
	}
	fmt.Println(string(acl))
}

/*-----------Input utils-----------*/

var sc = bufio.NewScanner(os.Stdin)

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

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

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

func readR() []rune {
	return []rune(readS())
}

func readI() int {
	i, _ := strconv.Atoi(readS())
	return i
}

func readF() float64 {
	f, _ := strconv.ParseFloat(readS(), 64)
	return f
}


Measured memory_bytes: 1780
#include<stdio.h>
void fanc(int,int);
	int map[13][13];
int main(void)
{
	int i,j;
	int c;
	char s[13];
	
	while(scanf("%s",s)!=EOF){
		c=0;
		for(i=0;i<12;i++){
			map[0][i]=s[i]-'0';
		}
		for(i=1;i<12;i++){
			scanf("%s",s);
			for(j=0;j<12;j++){
				map[i][j]=s[j]-'0';
			}
		}
	/*	for(i=0;i<12;i++){
			for(j=0;j<12;j++){
				printf("%d ",map[i][j]);
			}
			printf("\n");
		}*/
		for(i=0;i<12;i++){
			for(j=0;j<12;j++){
				if(map[i][j]==1){
					c++;
					map[i][j]=0;
					fanc(i,j);
				}
			}
		}
		printf("%d\n",c);
	}
	return 0;
}
void fanc(int x,int y)
{
	if(x+1<12){
		if(map[x+1][y]==1){
			map[x+1][y]=0;
			fanc(x+1,y);
		}
	}
	if(x-1>=0){
		if(map[x-1][y]==1){
			map[x-1][y]=0;
			fanc(x-1,y);
		}
	}
	if(y+1<12){
		if(map[x][y+1]==1){
			map[x][y+1]=0;
			fanc(x,y+1);
		}
	}
	if(y-1>=0){
		if(map[x][y-1]==1){
			map[x][y-1]=0;
			fanc(x,y-1);
		}
	}
}

Measured memory_bytes: 976
s = gets.strip
t = gets.strip

ans = nil
(0..s.size-t.size).each {|i|
  ok = 1
  (0..t.size-1).each{|j|
    if s[i+j] != ?? && s[i+j] != t[j] then
      ok = 0
    end
  }
  next if ok == 0
  result = ""
  (0..s.size-1).each{|j|
    if s[j] == ??
      if i <= j && j < i+t.size then
        result << t[j-i]
      else
        result << ?a
      end
    else
      result << s[j]
    end
  }
  ans = result if !ans || result < ans
}
if ans
  puts ans
else
  puts :UNRESTORABLE
end


Measured memory_bytes: 1788
#include<stdio.h>
main()
{
    char str[100000],a[100000];
    int i=0,j=0;
    scanf("%s",str);
    scanf("%s",a);
    if(strlen(str)>strlen(a))
    {

        while(i<strlen(str))
        {

            printf("%c",str[i]);
            i=i+1;
            printf("%c",a[j]);
            j=j+1;
            if(a[j]=='\0')
                break;
        }
        while(i<strlen(str))
        {
            printf("%c",str[i]);
            i=i+1;
        }
    }
    else
    {
        while(j<strlen(a))
        {

            printf("%c",str[i]);
            i=i+1;
            printf("%c",a[j]);
            j=j+1;
            if(str[i]=='\0')
                break;
        }
        while(j<strlen(a))
        {
            printf("%c",a[j]);
            j=j+1;
        }
    }

}

Measured memory_bytes: 128
K=int(input())
A=[1,2,3,4,5,6,7,8,9]
for _ in range(K-1):
    if K <= len(A): break
    K -= len(A)
    B=[]
    A,B=B,A
    for b in B:
        if b%10!=0: A.append(10*b+(b%10-1))
        A.append(10*b+b%10)
        if b%10!=9: A.append(10*b+(b%10+1))
print(A[K-1])

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

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;

#define INF (1<<(4*4-1))
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

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

   int N,M;
   cin>>N>>M;
   vector<vector<int> >E(N+1);
   vector<vector<int> >EE(N+1);
   vector<int>in(N+1,0),out(N+1,0);
   for(int i=0;i<N-1+M;i++){
     int A,B;
     cin>>A>>B;
     E[A].push_back(B);
     EE[B].push_back(A);
     out[A]++;
     in[B]++;
   }
   queue<int>S;
   for(int i=1;i<=N;i++)if(in[i]==0)S.push(i);
   vector<int>dag;
   while(S.size()){
     int now = S.front();
     S.pop();
     dag.push_back(now);
     for(int i=0;i<E[now].size();i++){
       int out=E[now][i];
       --in[out];
       if(in[out]==0){
        S.push(out);
       }
     }
   }

   vector<int>DAG(N+1);
   for(int i=0;i<N;i++){
     DAG[dag[i]]=i;
   }

   vector<int>ans(N+1,1);
   ans[dag[0]] = 0;
   for(int i=1;i<N;i++){
     int Max = -1;
     for(int j=0;j<EE[dag[i]].size();j++){
       Max=max(DAG[EE[dag[i]][j]],Max);
     }
     ans[dag[i]]=dag[Max];
   }
   for(int i=1;i<=N;i++)cout<<ans[i]<<endl;
   return 0;
}


Measured memory_bytes: 13820
#include "bits/stdc++.h"
#define MAXN 100009
#define INF 1000000007
#define mp(x,y) make_pair(x,y)
#define all(v) v.begin(),v.end()
#define pb(x) push_back(x)
#define wr cout<<"----------------"<<endl;
#define ppb() pop_back()
#define tr(ii,c) for(__typeof((c).begin()) ii=(c).begin();ii!=(c).end();ii++)
#define ff first
#define ss second
#define my_little_dodge 46
#define debug(x)  cerr<< #x <<" = "<< x<<endl;
using namespace std;

typedef long long ll;
typedef pair<int,int> PII;
template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
char s[MAXN];
int main(){
	//~ #ifndef ONLINE_JUDGE
    //~ freopen("file.in", "r", stdin);
	//~ #endif	
	int n;
	scanf("%d",&n);
	scanf("%s",s);
	int open=0,par=0;
	for(int i=0;i<n;i++){
		if(s[i]=='(')
			par++;
		else
			par--;
		while(par<0)
			open++,par++;	
	}
	while(open--)
		printf("(");
	for(int i=0;i<n;i++)
		printf("%c",s[i]);
	while(par--)
		printf(")");
	puts("");		
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>

using namespace std;
typedef long long ll;

using Edge = pair<ll,ll>; // toと重み
using tree = vector<vector<Edge>>;

int N_MAX = 100100;
int N;
tree Tree(N_MAX);
vector<ll> col(N_MAX);
set<int> se;

void dfs(int u,int p,int cost){
    col[u]=cost&1;
    if(se.size()==N) return;
    
    for(auto e : Tree[u]){
        if(e.first==p) continue;
        se.insert(e.first);
        dfs(e.first,u,cost+e.second);
    }
}

int main(){
    cin >> N;
    for(int i=0;i<N-1;i++){
        int u,v,w;
        cin >> u >> v >>w;
        u--,v--;
        Tree[u].push_back(Edge(v,w));
        Tree[v].push_back(Edge(u,w));
    }
    for(int i=0;i<N;i++){
        col[i]=-1;
    }
    
    se.insert(0);
    dfs(0,-1,0);
    for(int i=0;i<N;i++){
        cout << col[i] << endl;
    }
}


Measured memory_bytes: 16896
N,M,Q = map(int,input().split())
a = [0]*Q
b = [0]*Q
c = [0]*Q
d = [0]*Q
for i in range(Q):
    a[i],b[i],c[i],d[i] = map(int,input().split())
    a[i] -= 1  #a,bを0オリジンにそろえる
    b[i] -= 1  

def score(A):
    score = 0
    for ai, bi, ci, di in zip(a, b, c, d):
        if A[bi] - A[ai] == ci:
            score += di
    return score

def dfs(A):
    if len(A) == N:
        return score(A)
    res = 0
    prev_last = A[-1] if len(A) > 0 else 0
    for v in range(prev_last, M):
        A.append(v)
        res = max(res, dfs(A))
        A.pop()
    return res

print(dfs([]))

Measured memory_bytes: 81528
import sys
from bisect import bisect_left as bl
from bisect import bisect_right as br
input = sys.stdin.buffer.readline
N = int(input())
L = list(map(int, input().split()))
L.sort()
dl = []
res = 0
for i in range(N - 1):
  for j in range(i + 1, N):
    d0 = L[i] + L[j]
    d1 = i
    d2 = j
    d3 = abs(L[i] - L[j])
    ind = bl(L, d0)
    ind2 = br(L, d3)
    res += ind - ind2
    if ind2 <= d1 <= ind:
      res -= 1
    if ind2 <= d2 <= ind:
      res -= 1
  #print(res, d, ind, ind2)
print(res // 3)

Measured memory_bytes: 49644
#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma comment(linker, "/stack:200000000")

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;

#define X first
#define Y second

//#include <boost/unordered_map.hpp>
//using namespace boost;

/*
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> rbtree;
rbtree T;
*/

namespace io{
	const int L = (1 << 20) + 1;

	char buf[L], *S , *T, c;

	char getchar() {
		if(__builtin_expect(S == T, 0)) {
			T = (S = buf) + fread(buf, 1, L, stdin);
			return (S == T ? EOF : *S++);
		}
		return *S++;
	}

	int inp() {
		int x = 0, f = 1; char ch;
		for(ch = getchar(); !isdigit(ch); ch = getchar())
			if(ch == '-') f = -1;
		for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
		return x * f;
	}

	unsigned inpu()
	{
		unsigned x = 0; char ch;
		for(ch = getchar(); !isdigit(ch); ch = getchar());
		for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
		return x;
	}

	ll inp_ll() {
		ll x = 0; int f = 1; char ch;
		for(ch = getchar(); !isdigit(ch); ch = getchar())
			if(ch == '-') f = -1;
		for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
		return x * f;
	}

	char B[45], *outs=B+40, *outr=B+40;
	template<class T>
	inline void print(register T a,register char x=0){
		if(x) *--outs = x, x = 0;

		if(!a)*--outs = '0';
		else
			while(a)
				*--outs = (a % 10) + 48, a /= 10;

		if(x)
			*--outs = x;

		fwrite(outs, outr - outs , 1, stdout);
		outs = outr;
	}
};

using io :: print;
using io :: inp;
using io :: inpu;
using io :: inp_ll;

using i32 = int;
using i64 = long long;
using u8 = unsigned char;
using u32 = unsigned;
using u64 = unsigned long long;
using f64 = double;
using f80 = long double;
//using i128 = __int128_t;
//using u128 = __uint128_t;
using i128 = i64;
using u128 = u64;

ll power(ll a, ll b, ll p)
{
	if (!b) return 1;
	ll t = power(a, b/2, p);
	t = t*t%p;
	if (b&1) t = t*a%p;
	return t;
}

ll exgcd(ll a, ll b, ll &x, ll &y)
{
	if (b == 0)
	{
		x = 1;
		y = 0;
		return a;
	}
	ll px, py;
	ll d = exgcd(b, a%b, px, py);
	x = py;
	y = px-a/b*py;
	return d;
}

template<class T>
inline void freshmin(T &a, const T &b)
{
	if (a > b) a = b;
}

template<class T>
inline void freshmax(T &a, const T &b)
{
	if (a < b) a = b;
}

const int MOD = 1000000007;
const int INF = 1000000000;
const int MAXN = 100010;

int n;
int a[MAXN], p[MAXN];

int main()
{
	
	ll n, a, b, c, d, e;
	cin >> n >> a >> b >> c >> d >> e;
	ll x = min({a, b, c, d, e});
	cout << 5+(n-1)/x << endl;
	
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner
import scala.collection.Searching._

import scala.annotation.tailrec

class IUnionFind(val size: Int) {

  private case class Node(var parent: Option[Int], var treeSize: Int)

  private val nodes = Array.fill[Node](size)(new Node(None, 1))

  def union(t1: Int, t2: Int): IUnionFind = {
    if (t1 == t2) return this

    val root1 = root(t1)
    val root2 = root(t2)
    if (root1 == root2) return this

    val node1 = nodes(root1)
    val node2 = nodes(root2)

    if (node1.treeSize < node2.treeSize) {
      node1.parent = Some(t2)
      node2.treeSize += node1.treeSize
    } else {
      node2.parent = Some(t1)
      node1.treeSize += node2.treeSize
    }
    this
  }

  def connected(t1: Int, t2: Int): Boolean = t1 == t2 || root(t1) == root(t2)

  @tailrec
  private def root(t: Int): Int = nodes(t).parent match {
    case None => t
    case Some(p) => root(p)
  }
}


object Main {
  def solve(sc: => Scanner): Unit = {
    val A = Array.fill[String](sc.nextInt)(sc.next)
    if (A.length != 0) {
      var min = -10000000000000L
      var max = 10000000000000L
      var f = true
      for (i <- 0 until A.length - 1) {
        if (A(i) == "x" && A(i + 1) == "x") {
          f = false
        } else {
          if (i % 2 == 0) {
            if (A(i) != "x" && A(i + 1) != "x" && A(i).toInt > A(i + 1).toInt) {
              f = false
            } else if (A(i) == "x") {
              max = math.min(max, A(i + 1).toInt)
            } else if (A(i + 1) == "x") {
              min = math.max(min, A(i).toInt)
            }
          } else {
            if (A(i) != "x" && A(i + 1) != "x" && A(i).toInt < A(i + 1).toInt) {
              f = false
            } else if (A(i) == "x") {
              min = math.max(min, A(i + 1).toInt)
            } else if (A(i + 1) == "x") {
              max = math.min(max, A(i).toInt)
            }
          }
        }
      }
      if (f) {
        if (max - min == 2) {
          println(min + 1)
        } else {
          if (max - min < 2) {
            println("none")
          } else {
            println("ambiguous")
          }
        }
      } else {
        println("none")
      }

      solve(sc)
    }
  }

  def main(args: Array[String]): Unit = {
    val sc: Scanner = new Scanner(System.in)

    solve(sc)
  }
}

Measured memory_bytes: 73060
N = int(input())
S1 = input()
S2 = input()

mod = 10 ** 9 + 7

ans = 0
ptn = 0
i = 0
if S1[i] == S2[i]:
    ans = 3
    ptn = 0
    i += 1
else:
    ans = 6
    ptn = 1
    i += 2

while i < N:
    if S1[i] == S2[i]:
        if ptn == 0:
            ans *= 2
        ptn = 0
        i += 1
    else:
        if ptn == 0:
            ans *= 2
        else:
            ans *= 3
        ptn = 1
        i += 2
print(ans % mod)

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

int main() {
  int a,b;
  cin >> a>>b;
  if(b%a == 0) cout << a+b << endl;
  else cout << b-a << endl;
}
  


Measured memory_bytes: 256
import static java.util.Arrays.deepToString;

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		new Main().run();
	}
	void tr(Object... os) {
		System.err.println(deepToString(os));
	}

	Scanner sc = new Scanner(System.in);
	public void run() {
		for (;sc.hasNext();) {
			String line = sc.nextLine();
			line = line.replaceAll("apple", "りんご");
			line = line.replaceAll("peach", "apple");
			line = line.replaceAll("りんご", "peach");
			System.out.println(line);
		}
	}
}

Measured memory_bytes: 17124
//Patwari26
#include<bits/stdc++.h>
using namespace std;
#define int         long long
#define ll          long long
#define pb          push_back
#define endl        '\n'
#define mii         map<ll,ll>
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (ll)x.size()
#define hell        1000000007
#define INF         (1ll<<60)
#define rep(i,a,b)  for(ll i=a;i<=b;i++)
#define rrep(i,a,b)  for(ll i=a;i>=b;i--)
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }
const int N=55;
int dis[N][2505];
vector<pair<ll,pii>> adj[N];
int c[N],d[N],s;
void dijkstra(int source,int nodes){
    memset(dis,-1,sizeof(dis));
    // rep(i,1,nodes+1) dis[i]=-1;
    using T=pair<int,pii>;
    priority_queue<T,vector<T>,greater<T>> pq;
    pq.push({0,{source,s}});
    while(!pq.empty()){
        auto g=pq.top();
        int silver=g.y.y;
        int node=g.y.x;
        pq.pop();
        if(dis[node][silver]!=-1) continue;
        dis[node][silver]=g.first;
        if(silver+c[node]<=2500) pq.push({g.x+d[node],{node,silver+c[node]}});
        for(auto i:adj[node]){
            if(silver>=i.y.x && dis[i.first][silver-i.y.x]==-1){
                pq.push({g.first+i.second.y,{i.first,silver-i.y.x}});
            }
        }
    }
}
void solve(){
    ll n,m,x,y,a,b;
    cin>>n>>m>>s;
    s=min(s,2500ll);
    rep(i,1,m){
        cin>>x>>y>>a>>b;
        adj[x].pb({y,{a,b}});
        adj[y].pb({x,{a,b}});
    }
    rep(i,1,n) cin>>c[i]>>d[i];
    dijkstra(1,n);
    rep(i,2,n){
        ll curr=INF;
        rep(j,0,2500){
            if(dis[i][j]!=-1) curr=min(curr,dis[i][j]);
        }
        cout<<curr<<endl;
    }
}
signed main()
{
    ios
    int TESTS=1;
    //cin>>TESTS;
    while(TESTS--){
        solve();
    }
    time
    return 0;
}

Measured memory_bytes: 10548
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int i=(m);(i)<(n);(i)++)
typedef long long ll;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int dp[100010];

int main(){
    int n;
    cin >> n;
    rep(i,n+1){
        dp[i]=1<<10;
    }
    dp[0]= 0;
    rep(i,n+1){
        for(int pow6 = 1;i+pow6<n+1;pow6*=6){
            dp[i+pow6] = min(dp[i+pow6],dp[i]+1);
        }
        for(int pow9 = 1;i+pow9<n+1;pow9*=9){
            dp[i+pow9] = min(dp[i+pow9],dp[i]+1);
        }
    }

    cout << dp[n] << endl;
    return 0;
}


Measured memory_bytes: 640
#include<stdio.h>
  int main(){
    int r,g,b;
    int sum;

    scanf("%d%d%d",&r,&g,&b);
    sum = r*100+g*10+b;
    if( sum%4 == 0 ){
      printf("YES");
    }else{
      printf("NO");
    }
  }


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

using namespace std;

#define range(i, m, n) for(int i = m; i < n; i++)
#define husk(i, m, n) for(int i = m; i > n; i--)

int n;

int main() {
  cin >> n;
  vector<int> p(n * n);
  range(i, 0, n * n) cin >> p[i];
  vector<vector<int>> res(n, vector<int>(n));
  vector<vector<int>> was(n, vector<int>(n, 1));
  range(i, 0, n) {
    range(j, 0, n) res[i][j] = min(min(i, n - i - 1), min(j, n - j - 1));
  }
  vector<int> dx = {0, 0, -1, 1};
  vector<int> dy = {1, -1, 0, 0};
  function<void(int, int)> dfs = [&](int x, int y) {
    range(rot, 0, 4) {
      int sx = x + dx[rot];
      int sy = y + dy[rot];
      if(sx < 0 || sx >= n || sy < 0 || sy >= n) continue;
      if(res[sx][sy] > res[x][y] + was[x][y]) {
        res[sx][sy] = res[x][y] + was[x][y];
        dfs(sx, sy);
      }
    }
  };
  int ans = 0;
  for(int i : p) {
    i--;
    int x = i / n;
    int y = i % n;
    ans += res[x][y];
    was[x][y] = 0;
    dfs(x, y);
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 29304
#include <cstdio>  
#include <algorithm>
using namespace std;  
int main() { 	
	int a,b,c;
	int d;
	scanf("%d %d", &a, &b);
	if(a<=8 && b<=8){
		printf("Yay!");
	}
	else{
		printf(":(");
	}
}







Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(long long i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,N-1,0)
#define RREPS(i,n) RFOR(i,N,1)
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
const int INF=1e18;
const int MOD=1e9+7;

signed main(){
    int N;cin>>N;
    map<int,int>memo;
    memo[0]++;
    int sum=0;
    REP(i,N){
        int a;cin>>a;
        sum+=a;
        memo[sum]++;
    }
    int ans=0;
    for(auto v:memo){
        ans+=v.second*(v.second-1)/2;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 15996
#include <iostream>
#include <vector>
#define ll long long
using namespace std;

int main() {
	int N;
	cin >> N;
	vector<ll> a(N);
	for(int i=0; i<N; ++i) cin >> a[i];
	ll ans=a[0]-1, now=2;
	for(int i=1; i<N; ++i){
	    if(a[i]==now) ++now;
	    else if(a[i]>now){
	        ans += a[i]/now-(a[i]%now==0 ? 1 : 0);
	    }
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AC_ItoHC
{
    class Program
    {
        static int numType = 26;
        int D;

        static void Main(string[] args) => new Program().Run();

        void Run()
        {
            var st = new DateTime();
            var limit = 1800;

            D = int.Parse(Console.ReadLine());
            var c = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var s = new int[D][];
            for (int i = 0; i < D; i++)
            {
                s[i] = Console.ReadLine().Split().Select(int.Parse).ToArray();
            }

            var ans = Solve();
            var score = CalcScore(c, s, ans);
            while ((DateTime.Now - st).TotalMilliseconds <= limit)
            {
                var newAns = Solve();
                var newScore = CalcScore(c, s, newAns);

                if (score > newScore)
                {
                    score = newScore;
                    ans = newAns;
                }
            }

            for (int i = 0; i < D; i++)
            {
                Console.WriteLine(ans[i]);
            }
        }

        private int[] Solve()
        {
            var ret = new int[D];
            var r = new Random();
            for (int i = 0; i < D; i++)
            {
                ret[i] = r.Next() % numType + 1;
            }

            return ret;
        }

        private int CalcScore(int[] c, int[][] s, int[] t)
        {
            var score = 0;
            var lastD = new int[numType];

            for (int d = 0; d < D; d++)
            {
                for (int i = 0; i < numType; i++)
                {
                    lastD[i]++;
                    if (i == t[d] - 1) lastD[i] = 0;
                }

                score += s[d][t[d] - 1];

                for (int i = 0; i < numType; i++)
                {
                    score -= lastD[i] * c[i];
                }
            }

            return score;
        }
    }
}


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

int main(){
    ll N;
    cin >> N;
    ll sum=0;
    rep(i,N){
        sum += i;
    }
    cout << sum << endl;
}


Measured memory_bytes: 256
n = gets.chomp.to_i
a = gets.chomp.split.map(&:to_i)

current = 1
ans = 0
any =false
a.each do |e|
  if e == current
    current += 1
    any = true
  else
    ans += 1
  end
end

if any
  puts ans
else
  puts -1
end

Measured memory_bytes: 16772
#!python3.8
# -*- coding: utf-8 -*-
# abc163/abc163_a
import sys
import math

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [i2s() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    R = i2n()
    print(R * math.pi * 2)
    return

main()


Measured memory_bytes: 9172
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) (v).begin(),(v).end()
#define out(a) cout << (a) << endl
using namespace std;
using ll = long long;

bool is_prime(int n){
    if (n < 2) return false;
    else if (n == 2) return true;
    else if (n % 2 == 0) return false;

    double sqrtn = sqrt(n);
    for (int i=3; i<=sqrtn; i+=2){
        if(n % i == 0) return false;
    }
    return true;
}

int main(){
    int n; 
    cin >> n;
    while(true){
        if(is_prime(n)){
            out(n);
            return 0;
        }
        n++;
    }
}

Measured memory_bytes: 256