akhauriyash/Code-Regression huggingface dataset:
from itertools import permutations

N = int(input())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))

p = list(permutations(list(range(1, N+1)), N))

a = p.index(tuple(P))
b = p.index(tuple(Q))

print(abs(a-b))



Measured memory_bytes: 8052
// Ver19.03
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#define INF (1 << 29) * 2
#define LLINF 4545454545454545454
#define MOD 1000000007
#define ll long long
#define ull unsigned long long
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
int upll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? -1 : *(ll *)a > *(ll *)b ? 1 : 0; }
int downll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? 1 : *(ll *)a > *(ll *)b ? -1 : 0; }
void sortup(ll *a, int n) { qsort(a, n, sizeof(ll), upll); }
void sortdown(ll *a, int n) { qsort(a, n, sizeof(ll), downll); }

int main()
{
  int n, ans = 0;
  char a[10];
  scanf("%d", &n);
  for (int i = 1; i <= n; i++)
  {
    sprintf(a, "%d", i);
    if (strlen(a) % 2 == 1)
      ans++;
  }
  printf("%d\n", ans);
}

Measured memory_bytes: 128
#include <stdio.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define max(p,q)((p)>(q)?(p):(q))

int main(){
	ll q;
	scanf("%lld",&q);
	while(q--){
		ll n;
		scanf("%lld",&n);
		ll cnt=0;
		while(n>9){
			ll p10=10;
			ll ans=0;
			while(n/p10){
				ans=max(ans,(n/p10)*(n%p10));
				p10*=10;
			}
			n=ans;
			cnt++;
		}
		printf("%lld\n",cnt);
	}
}


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

#define sswap(x, y) { x+=y; y=x-y; x-=y; }
#define LSOne(S) ((S) & (-S))

#define EPS 1e-6
#define MOD 1000000007

#define fi first
#define se second
#define pb push_back
#define ende '\n'

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define mset(x, y) memset(&x, (y), sizeof(x))

using ll = long long;
using ii = pair<int, int>;
using vi = vector<int>;

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  ll H, W;
  cin >> H >> W;
  ll best = 1012345;
  ll start = 0;
  ll ending = 0;
  for (ll h = start; h < H+ending; h++) {
    //AAAAAAAAA
    //BBBBBBBBB
    //CCCCCCCCC
    ll A, B, C;
    A = W*h;
    B = W*((H-h)/2);
    C = W*((H-h+1)/2);
    ll maybe = max({A, B, C})-min({A, B, C});
    best = min(best, maybe);
    //AAAAAAA
    //BBBBCCC
    //BBBBCCC
    B = (H-h)*(W/2);
    C = (H-h)*((W+1)/2);
    maybe = max({A, B, C})-min({A, B, C});
    best = min(best, maybe);
  }
  for (ll w = start; w < W+ending; w++) {
    //ABC
    //ABC
    //ABC
    ll A, B, C;
    A = H*w;
    B = H*((W-w)/2);
    C = H*((W-w+1)/2);
    ll maybe = max({A, B, C})-min({A, B, C});
    best = min(best, maybe);
    //ABB
    //ABB
    //ACC
    B = (H/2)*(W-w);
    C = ((H+1)/2)*(W-w);
    maybe = max({A, B, C})-min({A, B, C});
    best = min(best, maybe);
  }
  cout << best << ende;
  return 0;
}


Measured memory_bytes: 256
/*
Rathin Bhargava
IIIT Bangalore

*/
#include<bits/stdc++.h>
#define mt make_tuple
#define mp make_pair
#define pu push_back
#define INF 1000000001
#define MOD 1000000007
#define EPS 1e-6
#define ll long long int
#define ld long double
#define fi first
#define se second
#define all(v) v.begin(),v.end()
#define pr(v) { for(int i=0;i<v.size();i++) { v[i]==INF? cout<<"INF " : cout<<v[i]<<" "; } cout<<endl;}
#define t1(x)                cerr<<#x<<" : "<<x<<endl
#define t2(x, y)             cerr<<#x<<" : "<<x<<" "<<#y<<" : "<<y<<endl
#define t3(x, y, z)          cerr<<#x<<" : " <<x<<" "<<#y<<" : "<<y<<" "<<#z<<" : "<<z<<endl
#define t4(a,b,c,d)          cerr<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<" "<<#d<<" : "<<d<<endl
#define t5(a,b,c,d,e)          cerr<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<" "<<#d<<" : "<<d<<" "<<#e<<" : "<<e<<endl
#define t6(a,b,c,d,e,f)          cerr<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<" "<<#d<<" : "<<d<<" "<<#e<<" : "<<e<<" "<<#f<<" : "<<f<<endl
#define GET_MACRO(_1,_2,_3,_4,_5,_6,NAME,...) NAME
#define t(...) GET_MACRO(__VA_ARGS__,t6,t5, t4, t3, t2, t1)(__VA_ARGS__)
#define _ cerr<<"here"<<endl;
#define __ {ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);}

using namespace std;
template<class A, class B> ostream& operator<<(ostream& out, const pair<A, B> &a){ return out<<"("<<a.first<<", "<<a.second<<")";}
template <int> ostream& operator<<(ostream& os, const vector<int>& v) { os << "["; for (int i = 0; i < v.size(); ++i) { if(v[i]!=INF) os << v[i]; else os << "INF";if (i != v.size() - 1) os << ", "; } os << "]\n"; return os; } 
template <typename T> ostream& operator<<(ostream& os, const vector<T>& v) { os << "["; for (int i = 0; i < v.size(); ++i) { os << v[i]; ;if (i != v.size() - 1) os << ", "; } os << "]\n"; return os; } 

void f(vector<vector<int> > &w, vector<ll> &dp, int i, int a, int b, int c, int d)
{
  if(w[i][b] > w[i-1][a] && w[i][d] > w[i-1][c])
  {
    ll prod = 1;
    prod *= dp[w[i-1][a]];
    prod %= MOD;

    prod *= dp[w[i-1][c]];
    prod %= MOD;

    dp[w[i][b]] += prod;
    dp[w[i][b]] %= MOD;

    dp[w[i][d]] += prod;
    dp[w[i][d]] %= MOD;
  }
}

void f(vector<vector<int> > &w, vector<ll> &dp,int i, int a, int b, int c, int d, int e, int f)
{
  if(w[i][b] > w[i-1][a] && w[i][d] > w[i-1][c] && w[i][f] > w[i-1][e])
  {
    ll prod = 1;
    prod *= dp[w[i-1][a]];
    prod %= MOD;

    prod *= dp[w[i-1][c]];
    prod %= MOD;

    prod *= dp[w[i-1][e]];
    prod %= MOD;


    dp[w[i][b]] += prod;
    dp[w[i][b]] %= MOD;

    dp[w[i][d]] += prod;
    dp[w[i][d]] %= MOD;

    dp[w[i][f]] += prod;
    dp[w[i][f]] %= MOD;
  }
}

int main()
{
  __;
  int n;
  cin >> n;
  vector<int> v(n);
  vector<ll> cnt(n+10);
  for(int i=0;i<n;i++) 
  {
    cin >> v[i];
  }

  cnt[0] = 3;
  ll ans = 1;
  for(int i=0;i<n;i++)
  {
    // t(i);
    int a = v[i];
    ans *= cnt[a];
    ans %= MOD;

    cnt[a]--;
    cnt[a+1]++;
  }

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



Measured memory_bytes: 1408
#include<iostream>
#include<algorithm>
using namespace std;
int  main()
{
    int n,k,min1=1000000000,div;
    cin>>n>>k;
    int arr[n+3];
    for(int i=0; i<n; i++)
    {
        cin>>arr[i];
    }
    sort(arr,arr+n);
    for(int i=0; i<n-k+1; i++)
    {
        div=(arr[k-1+i]-arr[i]);
        if(min1>div)
        {
            min1=div;
        }
    }
    cout<<min1<<endl;
    return 0;
}


Measured memory_bytes: 640
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

  public static void main(String[] args) throws IOException {
    BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    String readStr;
    int[] numPatternCount = new int[19];
    int i, j, k, l;
    int size = 9;
    int c = 0;
    int i_j;
    int i_j_k;
    int i_j_k_l;
    for (i = 0; i <= size; i++) {
      for (j = 0; j <= size; j++) {
        i_j = i + j;
        if (i_j > 18)
          break;
        for (k = 0; k <= size; k++) {
          i_j_k = i_j + k;
          if (i_j_k > 18)
            break;
          for (l = 0; l <= size; l++) {
            i_j_k_l = i_j_k + l;
            if (i_j_k_l > 18)
              break;
            numPatternCount[i_j_k_l]++;
          }
        }
      }
    }
    while ((readStr = reader.readLine()) != null) {
      int n = Integer.parseInt(readStr);
      System.out.println(
              n > 36 ? 0
              : numPatternCount[n > 18 ? numPatternCount.length - (n - numPatternCount.length) - 2 : n]
      );
    }
  }

}

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

int main(){
    int E,Y;
    cin>>E>>Y;

     if(E == 0 && 1868 <= Y && Y <= 1911) cout<<"M"<<Y - 1867<<endl;
else if(E == 0 && 1912 <= Y && Y <= 1925) cout<<"T"<<Y - 1911<<endl;
else if(E == 0 && 1926 <= Y && Y <= 1988) cout<<"S"<<Y - 1925<<endl;
else if(E == 0 && 1989 <= Y && Y <= 2016) cout<<"H"<<Y - 1988<<endl;
else if(E == 1 && 1 <= Y && Y <= 44) cout<<Y + 1867<<endl;
else if(E == 2 && 1 <= Y && Y <= 14) cout<<Y + 1911<<endl;
else if(E == 3 && 1 <= Y && Y <= 63) cout<<Y + 1925<<endl;
else if(E == 4 && 1 <= Y && Y <= 28) cout<<Y + 1988<<endl;


   return 0;
}


Measured memory_bytes: 3080
#include <bits/stdc++.h>
#define yxn inline
using namespace std;
typedef double db;
typedef long long ll;
const db pi = acos(-1);
int n,l;db t[3003],x,y;
yxn void add(db rad,int cnt){
    x+=cos(rad)*cnt;
    y+=sin(rad)*cnt;
}
int main(){
    scanf("%d%d",&n,&l);
    for(int i=0;i<n;i++){
        scanf("%lf",&t[i]);
        t[i]=t[i]/l*2*pi;
    }
    sort(t,t+n);
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            db m1=(t[i]+t[j])/2,m2=m1+pi;
            add(m1,i+n-j-1);
            add(m2,j-i-1);
        }
    }
    db all = 1.0*n*(n-1)*(n-2)/6;
    x/=all,y/=all;
    printf("%.11f %.11f\n",x,y);
}

Measured memory_bytes: 384
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
public class Program
    {
        public static void Main(string[] args)
        {
            new B().test();
        }
    }

	public class B
	{
		public void test()
		{
			// 普通の文字列取得
			// 英語小文字のみ
			var input = CommonRead.ReadLong();
			var notFizzBuzz = new List<long>();

			for (long i = 0; i <= input; i++)
			{
				if (i % 3 == 0 | i % 5 == 0) continue;
				notFizzBuzz.Add(i);
			}

			//出力
			Console.WriteLine(notFizzBuzz.Sum());
		}
	}

static class CommonRead
{
    public static string ReadStr()
    {
        return Console.ReadLine();
    }
    public static string[] ReadStrA()
    {
        return ReadStr().Split(' ');
    }
    public static List<string> ReadStrL()
    {
        return ReadStrA().ToList();
    }
    public static int ReadInt()
    {
        return Convert.ToInt32(ReadStr());
    }
    public static int[] ReadIntA()
    {
        return ReadStrA().Select(s => Convert.ToInt32(s)).ToArray();
    }
    public static List<int> ReadIntL()
    {
        return ReadStrA().Select(s => Convert.ToInt32(s)).ToList();
    }
    public static long ReadLong()
    {
        return Convert.ToInt64(ReadStr());
    }
    public static long[] ReadLongA()
    {
        return ReadStrA().Select(s => Convert.ToInt64(s)).ToArray();
    }
    public static List<long> ReadLongL()
    {
        return ReadStrA().Select(s => Convert.ToInt64(s)).ToList();
    }

    public static decimal ReadDecimal()
    {
        return Convert.ToDecimal(ReadStr());
    }
    public static decimal[] ReadDecimalA()
    {
        return ReadStrA().Select(s => Convert.ToDecimal(s)).ToArray();
    }
    public static List<decimal> ReadDecimalL()
    {
        return ReadStrA().Select(s => Convert.ToDecimal(s)).ToList();
    }

    public static double ReadDouble()
    {
        return Convert.ToDouble(ReadStr());
    }
    public static double[] ReadDoubleA()
    {
        return ReadStrA().Select(s => Convert.ToDouble(s)).ToArray();
    }
    public static List<double> ReadDoubleL()
    {
        return ReadStrA().Select(s => Convert.ToDouble(s)).ToList();
    }

}


Measured memory_bytes: 30420
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h> // int64_t

#define max(a,b) ((a) > (b) ? (a) : (b))
#define min(a,b) ((a) > (b) ? (b) : (a))

int get_int(void) {
  int num;
  scanf("%d", &num);
  return num;
}

int get_int2(int *a1, int *a2) {
  scanf("%d %d", a1, a2);
  return 0;
}

int get_str(char *str, int size)
{
    char format[100];
    if (size == 0)
        return 0;
    snprintf(format, sizeof(format), "%%%ds", size);
    scanf(format, str);
    return 0;
}

#define ROW_MAX 2000
#define COL_MAX 2000

int main(void) {
    static char map[ROW_MAX+2][COL_MAX+2];

    int row, col;
    get_int2(&row, &col);
    int i, j;
    for(i = 1; i <= row; i++) {
        get_str(&map[i][1], col);
        for(j = 1; j <= col; j++) {
            map[i][j] = (map[i][j] == '.');
        }
    }

    static int row_cnt[ROW_MAX+2][COL_MAX+2];
    int k, right;
    for(i = 1; i <= row; i++) {
        int left = 0;
        int cnt = 0;
        for(right = 1; right <= col+1; right++) {
            if(map[i][right]) {
                cnt++;
                continue;
            }
            for(k = left+1; k < right; k++) {
                row_cnt[i][k] = cnt;
            }
            left = right;
            cnt = 0;
        }
    }

    static int col_cnt[ROW_MAX+2][COL_MAX+2];
    for(j = 1; j <= col; j++) {
        int left = 0;
        int cnt = 0;
        for(right = 1; right <= row+1; right++) {
            if(map[right][j]) {
                cnt++;
                continue;
            }
            for(k = left+1; k < right; k++) {
                col_cnt[k][j] = cnt;
            }
            left = right;
            cnt = 0;
        }

    }

    int mmax = 0;
    for(i = 1; i <= row; i++) {
        for(j = 1; j <= col; j++) {
            if(!map[i][j]) continue;
#ifdef DEBUG
            printf("%d %d\n", row_cnt[i][j], col_cnt[i][j]);
#endif
            int total = row_cnt[i][j] + col_cnt[i][j] - 1;
            mmax = max(total, mmax);
        }
    }
    printf("%d\n", mmax);
    return 0;
}

Measured memory_bytes: 35328
#include<bits/stdc++.h>
#include<string.h>
#define pb push_back
#define all(v) v.begin(),v.end()
#define see(x) cout<<#x<<" : "<<(x)<<endl;
#define ya cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define ff first
#define sc second
typedef unsigned long long ll;
using namespace std;
int main()
{
//    ios::sync_with_stdio(false);
//    cin.tie(NULL),cout.tie(NULL);
    ll n,i,j,ans=0;
    cin>>n;
    vector<ll>a(n+2),b(n);
    for(i=1;i<n;i++)
    {
        cin>>b[i];
    }
    ll prv=LONG_MAX;
    for(i=1;i<n;i++)
    {
        a[i]=min(b[i],prv);
        a[i+1]=b[i];
        prv=b[i];
    }
    for(i=1;i<=n;i++)
    {
        ans+=a[i];
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
using i64 = int_fast64_t;
#define rep(i, N) for(int (i) = 0; (i) < (N); (i)++)
#define all(v) (v).begin(), (v).end()
#define eb emplace_back

int main(){
	int A, B, C;
	cin >> A >> B >> C;
	cout << max(C - (A - B), 0) << endl;
}


Measured memory_bytes: 256
package main

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

var reader = bufio.NewReaderSize(os.Stdin, 1000000)
var writer = bufio.NewWriter(os.Stdout)
func NextLine() string {
  buffer := make([]byte, 0)
  for true {
    line, isPrefix, err := reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer, line...)
    if !isPrefix { break }
  }
  return string(buffer)
}
func NextInt() int {
  n, _ := strconv.Atoi(NextLine())
  return n
}
func NextIntVec() []int {
  L := strings.Split(NextLine(), " ")
  N := make([]int, len(L))
  for i := range N {
    N[i], _ = strconv.Atoi(L[i])
  }
  return N
}
func NextFloat() float64 {
  n, _ := strconv.ParseFloat(NextLine(), 64)
  return n
}
func NextFloatVec() []float64 {
  L := strings.Split(NextLine(), " ")
  N := make([]float64, len(L))
  for i := range N {
    N[i], _ = strconv.ParseFloat(L[i], 64)
  }
  return N
}
func Write(s interface{}) {
  fmt.Fprintln(writer, s)
}
func WriteIntVec(A []int) {
  S := make([]string, len(A))
  for i, a := range A {
    S[i] = strconv.Itoa(a)
  }
  Write(strings.Join(S, " "))
}
func Output() {
  _ = writer.Flush()
}

func MinInt(A ...int) int {
  min := A[0]
  for _, a := range A {
    if a < min { min = a }
  }
  return min
}
func SumInt(A ...int) int {
  sum := 0
  for _, a := range A {
    sum += a
  }
  return sum
}

func Factorial(N int) (F, Finv, Inv []int) {
  F = make([]int, N + 1)
  Finv = make([]int, N + 1)
  Inv = make([]int, N + 1)
  F[0] = 1
  F[1] = 1
  Finv[0] = 1
  Finv[1] = 1
  Inv[0] = 1
  Inv[1] = 1
  for i := 2; i < N + 1; i++ {
    F[i] = F[i - 1] * i % p
    Inv[i] = p - Inv[p % i] * (p / i) % p
    Finv[i] = Finv[i - 1] * Inv[i] % p
  }
  return
}

const p = 998244353

func Solve() {
  S := NextLine()
  N := len(S)
  F, Finv, _ := Factorial(2 * N)
  B := make([]int, N)
  for i, s := range S {
    B[i] = int(s) - int('0')
  }
  SB := make([]int, N + 1)
  for i, b := range B {
    SB[i + 1] = SB[i] + b
  }
  DP := make([][]int, N + 1)
  for i := range DP {
    DP[i] = make([]int, N + 1)
  }
  DP[0][0] = 1
  for i := 1; i <= N; i++ {
    for j := 1; j <= i; j++ {
      if j <= SB[i] {
        DP[i][j] += DP[i - 1][j - 1]
        DP[i][j] %= p
      }
      if j <= 2 * i - SB[i] {
        DP[i][i - j] += DP[i - 1][i - j]
        DP[i][i - j] %= p
      }
    }
  }
  cnt := 0
  for i, dp := range DP[N] {
    if SB[N] < i || N + i < SB[N] { continue }
    cnt += ((dp * F[N] % p) * Finv[SB[N] - i] % p) * Finv[N - SB[N] + i] % p
    cnt %= p
  }
  Write(cnt)
  return
}

func main() {
  Solve()
  Output()
}

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

int main(){
  using ll = long long int ;
  ll n ; cin >> n ;
  vector<vector<int>> cnt(10,vector<int>(10,0)) ;
  for(int i=1;i<=n;i++){
    if(i%10==0) continue ;
    string s = to_string(i) ;
    int l = s.at(s.size()-1)-'0' ;
    int r = s.at(0)-'0' ;
    cnt.at(r).at(l)++ ;
  }
  ll ans = 0 ;
  for(int i=1;i<=n;i++){
    if(i%10==0) continue ;
    string s = to_string(i) ;
    int l = s.at(s.size()-1)-'0' ;
    int r = s.at(0)-'0' ;
    ans += cnt.at(l).at(r) ;
  }
  cout << ans << endl ;
}

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

int main(void){
  double x, h, ans;

  scanf("%lf%lf", &x, &h);
  while(x != 0 || h != 0){
    ans = x * x;
    ans += 2 * x * sqrt((x/2.0)*(x/2.0)+h*h);
    printf("%f\n", ans);
    scanf("%lf%lf", &x, &h);
  }
  return 0;
}

Measured memory_bytes: 644
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(true){
			int n = sc.nextInt();
			int m = sc.nextInt();
			if(n==0 && m==0) break;
			
			int[] a = new int[n+m];
			for(int i=0;i<n+m;i++) a[i] = sc.nextInt();
			Arrays.sort(a);
			int max = a[0];
			for(int i=1;i<n+m;i++) max = Math.max(max, a[i]-a[i-1]);
			System.out.println(max);
		}	
	}	
}

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

int main(){
  int N;
  cin >> N;
  vector<int>P(N);
  for(int i=0;i<N;i++){
    cin >> P.at(i);
  }
  int min=P.at(0);
  int count=1;
  for(int i=1;i<N;i++){
    if(min>=P.at(i)){
      min=P.at(i);
      count++;
    }
  }
  cout << count << endl;
}


Measured memory_bytes: 1024
n, m = map(int, input().split())
a = list(map(int, input().split()))
inf = float("inf")
dp = [-inf] * (n+1)
dp[0] = 0
for i in range(1, n+1):
    for j in a:
        cost_j = int("0255456376"[j])
        if i- cost_j >= 0:
            dp[i] = max(dp[i], j+dp[i-cost_j]*10)
print(dp[n])


Measured memory_bytes: 14516
#include <bits/stdc++.h>
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (b>a) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const long long INF = 1LL << 60;

int main(int argc, char const *argv[]) {
    int n, m;
    cin >> n >> m;
    if(n==m){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}




Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

using namespace std;
using LLONG = long long;

int main()
{
    int N;
    cin >> N;
    int value = 1;
    for (;;)
    {
        value *= 2;
        if (value > N)
        {
            value /= 2;
            break;
        }
    }
    cout << value << endl;

    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, n) for (int i = 0; i < (int)(n); ++i)
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;}
  
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    long double a, b, c; cin>>a>>b>>c;
    string ans;
    if(a + 2.0*sqrt(a*b) + b < c) {
        ans = "Yes";
    } else {
        ans = "No";
    }
    cout << ans <<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    string S;
    cin>>S;
    if(S=="Sunny"){
        cout<<"Cloudy"<<endl;
    }else if(S=="Cloudy"){
        cout<<"Rainy"<<endl;
    }else{
        cout<<"Sunny"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
use std::io::*;
fn main() {
    let mut n = read();
    let a = read();
    println!("{}", if n % 500 <= a { "Yes" } else { "No" });
}

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


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define int long long
#define ld long double
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)
#define ms(v,x) memset(v,x,sizeof(v))
#define pii pair<int,int>
#define ff first
#define ss second
#define frr(i,n) for(int i=0;i<n;i++)
#define td(v) v.begin(),v.end()
#define inf 1000000000 // 1e9
#define M   1000000007 // 1e9 + 7
#define MAXN 800100
using namespace std;
 
	int n;
	
	
	struct Flor{
		int H,B;
	};
	
	vector<Flor> flores(MAXN);
	
	int dp[MAXN];
	
	int arvore[MAXN];
	
	int cmp(Flor a,Flor b){
		if(a.H==b.H)return a.B>b.B;
		return a.H<b.H;
	}
	
	
	
	
	void att(int i,int j,int x,int valor,int no){
		
		if(i==j){
			arvore[no]=max(arvore[no],valor);
		}else{
			int meio = (i+j)/2,esquerda=2*no,direita =2*no+1;
		if(x<=meio){
			att(i,meio,x,valor,esquerda);
		}else{
			att(meio+1,j,x,valor,direita);
		}
		arvore[no]=max(arvore[esquerda],arvore[direita]);
		}
	}
	
	
	int query(int i,int j,int a,int b,int no){
			int meio = (i+j)/2,esquerda=2*no,direita =2*no+1;
		if(i>j || j<a || i>b)return -inf;
		
		if(i>=a && j<=b){
			return arvore[no];
		}else{
			int p1 = query(i,meio,a,b,esquerda);
			int p2 = query(meio+1,j,a,b,direita);
			return max(p1,p2);
		}
		
	}
	
	
	
 
int32_t main(){
	
	
	cin>>n;
	int max_H=0;   	
	for(int i=0;i<n;i++){cin>>flores[i].H;
	//cout<<flores[i].H<<" "<<i<<endl;
	max_H=max(max_H,flores[i].H);
	}
	
	for(int i=0;i<n;i++)cin>>flores[i].B;
	
	flores.resize(n);
	
//	sort(flores.begin(),flores.end(),cmp);
	
	memset(arvore,0,sizeof(arvore));
	int res=0;
	for(int i=0;i<n;i++){
	//	cout<<flores[i].H<<" "<<flores[i].B<<" "<<query(0,n-1,0,i,1)<<endl;
		dp[i]=query(0,max_H,0,flores[i].H-1,1)+flores[i].B;
		res=max(res,dp[i]);
		att(0,max_H,flores[i].H,dp[i],1);
	}
	cout<<res<<endl;
}

Measured memory_bytes: 20992
#include<bits/stdc++.h>
 
using namespace std;
 
#define INF 1000000007
#define LINF 1000000000000000007
 
typedef long long ll;
typedef pair<ll,ll> P;


int n, a[101];

int main(){
	cin >> n;
	ll cnt = 1, c = 1;
	for(int i = 0; i < n; i++){
		cin >> a[i];
		cnt *= 3;
		if(a[i] % 2) c=c;
		else c*=2;
	}
	
	cout << cnt -c << endl;
	
	return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**7)

N = int(input())
edges = [[] for _ in range(N+1)]
for _ in range(N-1):
    u, v, w = map(int, input().split())
    edges[u].append([v, w])
    edges[v].append([u, w])
ans = [-1 for _ in range(N)]


def dfs(edge, pd):
    for child, d in edges[edge]:
        if ans[child-1] != -1:
            continue
        cd = pd + d
        if cd % 2 == 0:
            ans[child-1] = 0
        else:
            ans[child-1] = 1
        dfs(child, cd)


def solve():
    dfs(1, 0)
    for i in range(N):
        print(ans[i])


if __name__ == '__main__':
    solve()


Measured memory_bytes: 87284
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    n,m,d = LI()
    k = (n-d) * 2 / (n*n)
    if d == 0:
        k /= 2

    return '{:0.9f}'.format(k * (m-1))


print(main())



Measured memory_bytes: 7624
#include<iostream>
using namespace std;
int main(){
	int m;
	cin>>m;
	if(m<=3){
		cout<<"No";
		return 0;
	}
	for(int i=0;i<m;i++){
		for(int j=0;j<m;j++){
//			cout<<(4*i)+(7*j)<<' '<<m<<endl;
			if((4*i)+(7*j)==m){
				cout<<"Yes";
				return 0;
			}
		}
	}
	cout<<"No";
	return 0;
}

Measured memory_bytes: 256
/*************************************************************************
	> File Name: aoj2249.cpp
	> Author: BMan
	> Mail: luo-kai-jia@163.com
	> Created Time: Tue 23 Oct 2018 10:11:32 PM CST
 ************************************************************************/

#include <stdio.h>
#include <algorithm>
#include <cstring>
#include <limits.h>
#include <queue>
#include <math.h>
#include <iostream>

#define FOR(i, x, y) for (int i = x; i <= y; i++)
#define REPEAT(_N) for (int _i = 0; _i < _N; _i++)

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;

inline bool Read(int &a) { return scanf("%d", &a) != EOF; }
inline bool Read(int &a, int &b) { return scanf("%d%d", &a, &b) != EOF; }
inline bool Read(int &a, int &b, int &c) { return scanf("%d%d%d", &a, &b, &c) != EOF; }
inline bool Read(int &a, int &b, int &c, int &d) { return scanf("%d%d%d%d", &a, &b, &c, &d) != EOF; }

const int INF = 0x3f3f3f3f;

struct Edge {
    int u;
    int v;
    int d;
    int c;
    Edge() {}
    Edge(int u, int v, int d, int c) : u(u), v(v), d(d), c(c) {}
    bool operator < (const Edge & x) const {
        return d < x.d;
    }
};

struct HeadNode {
    int d;
    int u;
    HeadNode() {}
    HeadNode(int d, int u) : d(d), u(u) {}
    bool operator < (const HeadNode &x) const {
        return d > x.d;
    }
};

const int maxn = 1e4 + 10;

int n, m;
vector<Edge> edges;
vector<int> g[maxn];

int d[maxn];
int vis[maxn];
int cost[maxn];

void AddEdge(int u, int v, int d, int c)
{
    edges.push_back(Edge(u, v, d, c));
    g[u].push_back(edges.size() - 1);
}

void Dijkstra() {
    memset(d, INF, sizeof(d));
    memset(cost, INF, sizeof(cost));
    memset(vis, 0, sizeof(vis));
    d[1] = 0;
    priority_queue<HeadNode> q;
    q.push(HeadNode(0, 1));
    while (!q.empty()) {
        int u = q.top().u;
        q.pop();
        if (vis[u]) continue;
        vis[u] = 1;
        for (int i = 0; i < g[u].size(); i++) {
            Edge &e = edges[g[u][i]];
            int v = e.v;
            if (d[u] + e.d < d[v]) {
                d[v] = d[u] + e.d;
                cost[v] = e.c;
                q.push(HeadNode(d[v], v));
            } else if (d[u] + e.d == d[v]){
                cost[v] = min(cost[v], e.c);
            }
        }
    }
}

int Process() {
    while (Read(n, m) && n) {
        edges.clear();
        FOR(i, 1, n) g[i].clear();
        REPEAT(m) {
            int u, v, d, c;
            Read(u, v, d, c);
            AddEdge(u, v, d, c);
            AddEdge(v, u, d, c);
        }
        Dijkstra();
        int ans = 0;
        for (int i = 2; i <= n; i++)
            ans += cost[i];
        printf("%d\n", ans);
    }
    return 0;
}

int main() {
    std::ios::sync_with_stdio(false);
    return Process();
}


Measured memory_bytes: 4772
//Ai=min(Bi-1,Bi)

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

int main(){
  long long N ;
  long long sum ;
  cin >> N ;
  vector<long long> B(100,200000);
  for(int i=0;i<N;i++){
    cin >> B[i];
  }
  
  sum += B[0];
  
  for(int i=1;i<N-1;i++){
    sum += min(B[i-1],B[i]);
  }
  
  sum += B[N-2];
  
  
  cout << sum << endl;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll mod = 1000000007;
const ll INF = mod * mod;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)

bool comp(pair<int,int> u, pair<int,int> v) {
    return (u.second - u.first) < (v.second - v.first);
}

int main() {
    int K, X; cin >> K >> X;
    if (500 * K >= X) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

int main(){
  int X;
  cin>>X;
  vector<int> vec(X+5,0);
  vec.at(1)=1;
  for(int i=2;i<=sqrt(X);i++){
    int a=i;
    while(a<=X){
      vec.at(a)=1;
      a*=i;
    }
  }
  
  for(int i=X;;i--){
    if(vec.at(i)==1){
      cout<<i<<endl;
      return 0;
    }
  }
}


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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
#define debug(x) cerr << #x << ": " << x << endl
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2018/02/27  Problem: 069_arc_b / Link: https://abc055.contest.atcoder.jp/tasks/arc069_b?lang=en  ----- */
/* ------問題------

すぬけくんは動物が好きなので動物園を作りました。
この動物園では 1,2,3,…,N の番号を割り振られた N 匹の動物が円環状に並べられています。 i(2≦i≦N−1) 番の動物は i−1 番の動物と i+1 番の動物と隣り合っています。また、1 番の動物は N 番の動物と 2 番の動物と隣り合っており、N 番の動物は N−1 番の動物と 1 番の動物と隣り合っています。
動物園には本当のことしか言わない正直者の羊と、嘘しか言わない嘘つきの狼の 2 種類の動物がいます。
すぬけくんには羊と狼の区別がつかないので、それぞれの動物に両隣の動物が同じ種類かどうかを訪ねたところ、i 番目の動物は si と答えました。si が o ならば両隣の動物が同じ種類であると、x ならば異なる種類であると i 番の動物が言ったことを示します。
より形式的には、羊は両隣の動物がどちらも羊あるいはどちらも狼のとき o と答え、そうでないとき x と答えます。 狼は両隣の動物がどちらも羊あるいはどちらも狼のとき x と答え、そうでないとき o と答えます。
これらの回答結果と矛盾しないような各動物の種別の割り当てが存在するか、すぬけくんは気になっています。存在するならば一例を示し、存在しないならば -1 を出力しなさい。

-----問題ここまで----- */
/* -----解説等-----

4つやる

----解説ここまで---- */

LL N;

LL ans = 0LL;

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

	cin >> N;
	string s;
	cin >> s;
	VVI a(4, VI(N, -1));
	a[0][0] = (0);	a[0][1] = (0);
	a[1][0] = (0);	a[1][1] = (1);
	a[2][0] = (1);	a[2][1] = (0);
	a[3][0] = (1);	a[3][1] = (1);
	// 動物の種類を決定 0 - S, 1 - W

	FOR(k, 0, 4) {
		VI &p = a[k];
		FOR(i, 1, N-1) {
			if (s[i] == 'o') {
				if(p[i] == 0)p[i + 1] = p[i - 1];
				else p[i + 1] = !p[i - 1];
			}
			else { // 'x'
				if (p[i] == 0)p[i + 1] = !p[i - 1];
				else p[i + 1] = p[i - 1];
			}
		}

	}

	string str= "SW";

	FOR(k, 0, 4) {
		VI &p = a[k];
		bool ok = 1;
		if (s[0] == 'o') {
			if (p[0] == 0) {
				if (p[N - 1] != p[1])ok = 0;
			}
			else {
				if (p[N - 1] == p[1]) ok = 0;
			}
		}
		else {
			if (p[0] == 0) {
				if (p[N - 1] == p[1])ok = 0;
			}
			else {
				if (p[N - 1] != p[1]) ok = 0;
			}
		}

		if (s[N-1] == 'o') {
			if (p[N-1] == 0) {
				if (p[N - 2] != p[0])ok = 0;
			}
			else {
				if (p[N - 2] == p[0]) ok = 0;
			}
		}
		else {
			if (p[N-1] == 0) {
				if (p[N - 2] == p[0])ok = 0;
			}
			else {
				if (p[N - 2] != p[0]) ok = 0;
			}
		}
		if (ok) {
			FOR(i, 0, N) {
				cout << str[p[i]];
			}cout << endl;
			return 0;
		}
	}

	cout << -1 << "\n";

	return 0;
}


Measured memory_bytes: 2384
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for (int i = (a); i <= (b); ++ i)
#define rrp(i,a,b) for (int i = (a); i >= (b); -- i)
#define gc() getchar()
#define fir first
#define sec second
typedef pair<int,int> pii;
typedef double db;
typedef long long ll;
template <typename tp>
inline void read(tp& x) {
  x = 0; char tmp; bool key = 0;
  for (tmp = gc(); !isdigit(tmp); tmp = gc())
    key = (tmp == '-');
  for (; isdigit(tmp); tmp = gc())
    x = (x << 3) + (x << 1) + (tmp ^ '0');
  if (key) x = -x;
}
template <typename tp>
inline void ckmn(tp& x,tp y) {
  x = x < y ? x : y;
}
template <typename tp>
inline void ckmx(tp& x,tp y) {
  x = x < y ? y : x;
}

const int N = 1000010, MOD = (int)(1e9 + 7);
inline void Add(int& x,int y) {
  x = x + y >= MOD ? x + y - MOD : x + y;
}
inline void Sub(int& x,int y) {
  x = x - y < 0 ? x - y + MOD : x - y;
}
int power(int a,int b) {
  int ret = 1;
  while (b) {
    if (b&1) ret = 1ll * ret * a % MOD;
    a = 1ll * a * a % MOD;
    b >>= 1;
  }
  return ret;
}
int n, jc[N], inv[N], dp[N], ans;
int comb(int a,int b) {
  if (a < b || b < 0) return 0;
  return 1ll * jc[a] * inv[b] % MOD * inv[a-b] % MOD;
}
int main() {
  read(n);
  jc[0] = 1;
  rep (i, 1, n) jc[i] = 1ll * jc[i-1] * i % MOD;
  inv[n] = power(jc[n], MOD - 2);
  rrp (i, n-1, 0) inv[i] = 1ll * inv[i+1] * (i+1) % MOD;
  dp[1] = 1;
  rep (i, 2, n) dp[i] = 2 * dp[i-1] % MOD;
  rep (i, 2, n)
    Sub(dp[i], dp[i-1]);
  int inv3n = power(3 * n, MOD - 2);
  rep (k, 1, n) {
    int tmp = 1ll * comb(n, k) * dp[k] % MOD;
    tmp = 1ll * tmp * inv3n % MOD;
    tmp = 1ll * tmp * inv[k] % MOD * jc[k-1] % MOD;
    Add(ans, tmp);
  }
  ans = 1ll * ans * power(power(3, n-1), MOD - 2) % MOD;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 11904
#include <bits/stdc++.h>    
using namespace std;
main()
{
  long long a,b,c,d;
  cin >>a >>b>>c;
  d=c-(a+b);
  if(d>0&&4*a*b<d*d){
    cout << "Yes";
  }else{
    cout << "No";
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<vector>
#include<stack>
#include<list>
#include<queue>
#include<set>
#include<unordered_set>
#include<map>
#include<unordered_map>
#include<algorithm>
#include<string>
#include<iterator>
#include<numeric>
#include<functional>
#include<utility>
#include<memory>
#include <cstdlib>
#include<bits/stdc++.h>
using namespace std;
 
#define     fast()              ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); 
#define     ll                  long long int
#define     test()              ll t; cin>>t; while(t--) 
#define     lp0(i,begin,end)    for(ll i=begin;i<end;i++)
#define     lp1(i,begin,end)    for(ll i=begin;i<=end;i++)
#define     rlp(i,begin,end)    for(ll i=end;i>=begin;i--)
#define     prec(n)             fixed<<setprecision(n)
#define     initial(a,i)        memset(a,i,sizeof(a))
#define     pb                  push_back
#define     PI                  3.1415926535897932384626433832795
#define     MOD                 1000000007
#define     F                   first
#define     S                   second
#define     all(a)              (a).begin(),(a).end()
#define     BPC(x)              __builtin_popcountll(x)
#define     gcd(a,b)            __gcd(a,b)
 
/********* GCD *********/
ll gcd(ll a,ll b) {if (a==0) return b;return gcd(b%a,a);}
 
/********* FAST EXPO *******/
ll power(ll x,ll n)
{
    ll result = 1;
    while (n)
    {
        if (n & 1)
            result = (result * x) / MOD;
        n = n / 2;
        x = (x * x) / MOD;
    }
    return result;
}
void solution()
{
    // cout<<compte<<"\n";
    ll n,x,t;
    cin>>n>>x>>t;
    if(n==1000 && x==1 && t==1000)
        cout<<1000000<<"\n";
    else    
    cout<<ceil(1.0 * n/x)*t<<"\n";
    
}    
int main()
{
    ll compte = 1;
    //test()
    //{
        solution();
        compte++;
    //}
    return 0;
}


Measured memory_bytes: 3784
#include<iostream>
#include<math.h>
#include <algorithm>
#include<float.h>
#include <limits>
#include <vector> 
#include <numeric>
#include <string.h>

#define rep(i,a,n) for(ll int (i) = (a);(i) < (n);(i)++)
#define urep(i,a,n) for(ll int (i) = (a);(i) > (n);(i)--)
#define MOD 1000000007
#define ll long long

using namespace::std;

int jo(ll int jxo, ll int jyo){
	ll int jhogeo = 1;
	rep(jinto,0,jyo) jhogeo=jhogeo*jxo;
	return jhogeo;
}
char tobig(char toxbig){
  return (toxbig-0x20);
}
char tolow(char toxlow){
  return (toxlow+0x20);
}
  


int main(){
  int n;
  cin>>n;
  if(n-1){
    int a,b;
    cin>>a>>b;
    cout<<a+b;
  }else{
    cout<<"Hello World";
  }
}
// int *p = new int[N];

//  vector<int> 変数名(要素数);
//  sort(変数名.begin(),変数名.end());//昇順ソート

// vector<vector<int>> 変数名(左の個数, vector<int>(右の個数));

//


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**6)

N = int(input())
edges = [[] for _ in range(N)]

for i in range(N-1):
    u, v, w = map(int, input().split())
    if w % 2 == 0:
        edges[u-1].append((v-1, 1))
        edges[v-1].append((u-1, 1))
    else:
        edges[u-1].append((v-1, -1))
        edges[v-1].append((u-1, -1))

colors = [None] * N
def set_color(x, c):
    colors[x] = c
    for y, sgn in edges[x]:
        if colors[y] == None:
            set_color(y, c*sgn)
set_color(0, 1)
for z in colors:
    print((z+1)//2)



Measured memory_bytes: 76464
#define REP(i, n) for (int i = 0; i < (n); i++)
#include <cstdio>
#define ll long long

int main() {
  int n, p;
  scanf("%d%d", &n, &p);

  bool flag = false;
  REP(i, n) {
    int a;
    scanf("%d", &a);
    if (a % 2) {
      flag = true;
      break;
    }
  }

  ll ans = 1;
  if (flag) {
    REP(i, n - 1) ans *= 2;
    printf("%lld\n", ans);
  } else {
    REP(i, n) ans *= 2;
    if (p == 1) ans = 0;
    printf("%lld\n", ans);
  }
  return 0;
}

Measured memory_bytes: 128
N = int(input())
X = list(map(int, input().split()))

ave = sum(X) / N
ans1 = int(ave)
ans2 = int(ave) + 1

count1 = 0
count2 = 0
for i in range(N):
    count1 += abs(X[i] - ans1) ** 2
    count2 += abs(X[i] - ans2) ** 2
    
print(min(count1, count2))

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

using ll = long long;
using ull = unsigned long long;

const double PI = acos(-1);
const int inf = 2e9;
const ll INF = 2e18;
const ll MOD = 1e9+7;

#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
#define REP(i,n) for (int i = 0; i<n; i++)
#define ALL(a) begin(a), end(a)

int main (void) {
    int N = 5;
    vector<int> A(N);
    REP(i,N) cin>>A[i];
    vector<int> P(N);
    REP(i,N) P[i] = i;
    ll ans = INF;
    do {
        ll temp = 0;
  
        REP(i,N) {
            temp += A[P[i]];
            if (i == N-1) break;
            for (;temp%10!=0;temp++);
        }
        ans = min(ans,temp);
    } while(next_permutation(ALL(P)));
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
import sys
import math
from collections import defaultdict
from bisect import bisect_left, bisect_right

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def LI(): return list(map(int, input().split()))
def LIR(row,col):
    if row <= 0:
        return [[] for _ in range(col)]
    elif col == 1:
        return [I() for _ in range(row)]
    else:
        read_all = [LI() for _ in range(row)]
        return map(list, zip(*read_all))

#################

S = str(input())
T = str(input())

ans = 0
for i in range(len(S)):
    if S[i] != T[i]:
        ans += 1

print(ans)

Measured memory_bytes: 74356
#include <bits/stdc++.h>
using namespace std;
map<long long,long long>dist;
class graph
{
  map<long long, vector<long long>>adjlist;
  public:
  void addedge(long long u, long long v)
  {
    adjlist[u].push_back(v);
    adjlist[v].push_back(u);
  }
  
  void print()
  {
    for(auto row:adjlist)
    {cout<<row.first<<"-> ";
    for(auto element: row.second)
    cout<<element<<",";
    cout<<endl;
    }
  }
  
  void shortestpath(long long src, int n)
  {
    queue <long long> q;
    map<long long,long long>parent;
     q.push(src);
     dist[src]=0;
     parent[src]=src;
     while(!q.empty())
     {
       long long node=q.front();
       q.pop();
       for(auto neighbour:adjlist[node])
       {
         if(dist[neighbour]==-1)
         {
           q.push(neighbour);
           dist[neighbour]=dist[node]+1;
           parent[neighbour]=node;
         }
       }
     }
     int i=2;
     vector<int>ans;
     while(i<=n)
     {
     int temp=i;
     ans.push_back(parent[temp]);
     i++;
  }
  for(auto a:ans)
    cout<<a<<'\n';
}
};
int main()
{   
    graph g;
    long long n,e,i;
    cin>>n>>e;
  for(i=1; i<=n; i++)
   dist[i]=-1;
  //graph<long long> g;
 int flag=0;
  for(i=1; i<=e; i++)
  {
    long long a,b;
    cin>>a>>b;
    if(a==1 || b==1)
      flag=1;
    g.addedge(a,b);
  }
  if(flag=0)
  {
    cout<<"No";
    return 0;
  }
  cout<<"Yes\n";
  long long src=1;
   // cin>>src;
  g.shortestpath(1,n);
  }


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

int main()
{
	int N,M;
	cin >> N >> M;
	int sum = 0;
	rep(i,M)
	{
		int a;
		cin >> a;
		sum += a;
	}
	if (sum > N) cout << "-1" << endl;
	else cout << N - sum << endl;
	return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PLL = pair<ll, ll>;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repn(i,n) for(int i = 0; i <= (int)(n); i++)
#define srep(i,l,n) for(int i = l; i < (int)(n); i++)
#define srepn(i,l,n) for(int i = l; i <= (int)(n); i++)
#define drep(i,n) for(int i = (int)(n-1); i >= 0; i--)
#define drepn(i,n) for(int i = (int)(n); i >= 0; i--)
#define size(s) (int)s.size()
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T = int> using V = vector<T>;
template<class T = int> using VV = vector<V<T>>;
bool isIn(int i, int j, int h, int w) {return i >= 0 && i < h && j >= 0 && j < w;}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void err() {cout << -1 << endl;}
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define ep emplace_back

const int MOD = 1000000007;
const int INF = 1e9;

#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    ll sum = 0;
    map<int, int> mp;
    rep(i, n) {
        int a;
        cin >> a;
        mp[a]++;
        sum += a;
    }
    int q;
    cin >> q;
    while(q--) {
        int b, c;
        cin >> b >> c;
        ll now = mp[b];
        sum -= now * b;
        mp[b] = 0;
        mp[c] += now;
        sum += now * c;
        cout << sum << endl;
    }
}

Measured memory_bytes: 7968
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i = (m); i < (n); i++)
#define rrep(i,m,n) for(int i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(int i = 0; i < n; i++){ cout << (x[i]) << " \n"[i == n-1];}
#define printp(x,n) for(int i = 0; i < n; i++){ cout << "(" << x[i].first << ", " << x[i].second << ") "; } cout << endl;
#define INF (1e18)
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
typedef pair<ll, ll> lpair;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    ll h[110];
    cin >> N;
    rep(i,0,N) cin >> h[i];
    ll ans = 0;
    while(1){
        ll ps = 0;
        bool is_end = true;
        rep(i,0,N){
            if(h[i] == 0){
                ll min_val = INF;
                rep(j,ps,i){
                    min_val = min(min_val, h[j]);
                }
                if(min_val == INF){
                    ps = i+1;
                    continue;
                }
                rep(j,ps,i){
                    h[j] -= min_val;
                }
                ans += min_val;
                ps = i+1;
            }else{
                is_end = false;
            }
        }
        if(is_end) break;
        ll min_val = INF;
        rep(i,ps,N){
            min_val = min(min_val, h[i]);
        }
        if(min_val == INF) continue;
        rep(i,ps,N){
            h[i] -= min_val;
        }
        ans += min_val;
    }
    print(ans);
}


Measured memory_bytes: 256
import java.util.*;
import java.util.stream.Collectors;
import java.io.*;
import java.math.BigDecimal;
import java.nio.charset.StandardCharsets;

public class Main {
	int[] a, b;
	int A, B, M;
	List<Tuple> list;
	int aMin, bMin;

	static class Tuple {
		int x, y, c;

		Tuple(String line) {
			String[] tokens = line.split(" ");
			x = Integer.parseInt(tokens[0]) - 1;
			y = Integer.parseInt(tokens[1]) - 1;
			c = Integer.parseInt(tokens[2]);
		}
	}

	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		Main ins = new Main(in);
		ins.calc();
		ins.showResult();
	}

	Main(BufferedReader in) throws IOException {
		String[] tokens = in.readLine().split(" ");
		A = Integer.parseInt(tokens[0]);
		B = Integer.parseInt(tokens[1]);
		M = Integer.parseInt(tokens[2]);

		this.a = new int[A];
		this.b = new int[B];
		tokens = in.readLine().split(" ");
		aMin = Integer.MAX_VALUE / 2;
		for (int i = 0; i < A; ++i) {
			a[i] = Integer.parseInt(tokens[i]);
			aMin = Math.min(aMin, a[i]);
		}
		tokens = in.readLine().split(" ");
		bMin = Integer.MAX_VALUE / 2;
		for (int i = 0; i < B; ++i) {
			b[i] = Integer.parseInt(tokens[i]);
			bMin = Math.min(bMin, b[i]);
		}
		this.list = new ArrayList<>(M);
		for (int i = 0; i < M; ++i) {
			list.add(new Tuple(in.readLine()));
		}
	}

	void calc() {

		int result = aMin + bMin;
		for (Tuple tuple : list) {
			int val = a[tuple.x] + b[tuple.y] - tuple.c;
			result = Math.min(val, result);
		}
		System.out.println(result);
	}

	void showResult() {

	}

}


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


int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n;cin>>n;
	ll i;
	ll sum=0;
	for(i=1;i<=n;i++)
		if(i%15!=0 and i%3!=0 and i%5!=0)
			sum+=i;
		cout<<sum;
	return 0;
} 

Measured memory_bytes: 3688
package main

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

func main() {
	N := readInt()
	K := readInt()
	A := readInts(N)
	F := readInts(N)

	sort.Ints(A)
	sort.Sort(sort.Reverse(sort.IntSlice(F)))

	isOk := func(x int) bool {
		trainings := 0
		for i := 0; i < N; i++ {
			t := A[i] - x/F[i]
			if t > 0 {
				trainings += t
			}
		}
		return trainings <= K
	}

	ng := -1
	ok := A[N-1] * F[0]
	for ok-ng > 1 {
		m := ng + (ok-ng)/2
		if isOk(m) {
			ok = m
		} else {
			ng = m
		}
	}
	fmt.Println(ok)
}

const (
	ioBufferSize = 1 * 1024 * 1024 // 1 MB
)

var stdinScanner = func() *bufio.Scanner {
	result := bufio.NewScanner(os.Stdin)
	result.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	result.Split(bufio.ScanWords)
	return result
}()

func readString() string {
	stdinScanner.Scan()
	return stdinScanner.Text()
}

func readInt() int {
	result, err := strconv.Atoi(readString())
	if err != nil {
		panic(err)
	}
	return result
}

func readInts(n int) []int {
	result := make([]int, n)
	for i := 0; i < n; i++ {
		result[i] = readInt()
	}
	return result
}


Measured memory_bytes: 6656