akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.util.*;

public class Main
{
	public static void main(String []args)throws IOException
	{
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		
		int n=Integer.parseInt(br.readLine());
		String []s=br.readLine().split(" ");
		
		double a[]=new double[n];
		
		for(int i=0;i<n;i++)
			a[i]=Double.parseDouble(s[i]);
					
					
		Arrays.sort(a);
		
		double sum=a[0];
		
		for(int i=1;i<n;i++)
			sum=((sum+a[i])/2.0);
			
		System.out.println(sum);	
		
	}
}




Measured memory_bytes: 21204
open Batteries
module EnumL = Enum.Labels
module ListL = List.Labels

let dbg0 x = Printf.eprintf "[debug]%s\n" @@ dump x
let dbg1 x = dbg0 x; x

let id = identity

let (++) n m = List.range n `To m
let (++^) n m = if n < m then List.range n `To (pred m) else []

let scan fmt = Scanf.sscanf (read_line ()) fmt

let scan_lines n fmt f =
  if n = 0 then Enum.empty ()
  else
    List.map (fun _ -> scan fmt f) (List.range 1 `To n)
    |> List.enum

let scan_list cnv =
  String.split_on_char ' ' @@ read_line ()
  |> List.map cnv

let scan_array cnv = Array.of_list @@ scan_list cnv

let scan_matrix n m e conv =
  let arr = Array.make_matrix n m e in
  ListL.iter (List.range 0 `To (pred n))
    ~f:(fun i -> arr.(i) <- Array.of_list @@ scan_list conv);
  arr

let rec powerset e =
  match Enum.get e with
  | None -> Enum.singleton @@ Enum.empty ()
  | Some v ->
    let f = powerset e in
    let g = Enum.clone f in
    EnumL.map f ~f:(fun x -> let y = Enum.clone x in push y v; y)
    |>  Enum.append g

let permutations l =
  let rec aux l =
    let rec interleave x = function
      | [] -> [[x]]
      | (hd::tl) as lst ->
        (x::lst) ::
        (ListL.map ~f:(List.cons hd)  @@ interleave x tl)
    in
    match l with
    | [] -> [[]]
    | hd::tl -> List.concat @@ List.map (interleave hd) @@ aux tl in
  let l = List.sort (List.compare Int.compare) @@ aux @@ List.of_enum l in
  List.enum % ListL.map ~f:List.enum @@ l

let intersection l =
  EnumL.filter ~f:(fun x -> EnumL.exists ~f:((=) x) @@ Enum.clone l)

let lower_bound n f =
  let rec aux l u =
    if abs @@ u - l > 1 then
      let m = (l + u) / 2 in
      if f m then aux l m
      else aux m u
    else u in aux (-1) n

let n = scan "%d" id
let a = scan_array Int.of_string
let b = scan_array Int.of_string
let c = scan_array Int.of_string

let () =
  Array.sort Int.compare a;
  Array.sort Int.compare b;
  Array.sort Int.compare c;
  let d = Array.of_list @@
    ListL.map (0 ++^ Array.length b) ~f:(fun i ->
        let i = lower_bound (Array.length c) (fun j -> b.(i) < c.(j)) in
        Array.length c - i) in
  ListL.iter (List.rev @@ 0 ++^ Array.length d) ~f:(fun i ->
      if i - 1 >= 0 then d.(i-1) <- d.(i-1) + d.(i));
  ListL.map (0 ++^ Array.length c) ~f:(fun i ->
      let i = lower_bound (Array.length b) (fun j -> a.(i) < b.(j)) in
      if i = Array.length b then 0
      else d.(i))
  |> List.sum
  |> Printf.printf "%d\n"


Measured memory_bytes: 18972
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) {
		FastReader s = new FastReader();
		
		int[] inp = new int[5];
		
		for(int i=0;i<5;++i)
			{
				inp[i] = s.nextInt();
				if(inp[i] == 0)
					System.out.println(i+1);
			}
		
		
	}
	
	static class FastReader {
        BufferedReader br;
        StringTokenizer st;
 
        public FastReader()
        {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }
 
        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException  e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
 
        int nextInt()
        {
            return Integer.parseInt(next());
        }
 
        long nextLong()
        {
            return Long.parseLong(next());
        }
 
        double nextDouble()
        {
            return Double.parseDouble(next());
        }
 
        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
	}

}


Measured memory_bytes: 32676
#include <bits/stdc++.h>
const int mod = 1e9 + 7;
inline int mul( int x , int y ){ return 1LL * x * y % mod ;}
int power_mod( int x , int y ){int ret = 1;while( y ){if( y & 1 ) ret = mul( ret , x );y >>= 1;x = mul( x , x );}return ret;}
inline int read(){int x=0,f=1;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}return x*f;}
using namespace std;
const int maxn = 1e5 + 50;

int N , a[maxn];
long long sum[maxn];

int main(int argc,char *argv[]){
	N = read();
	for(int i = 1 ; i <= N ; ++ i)
		a[i] = read();
	sort( a + 1 , a + N + 1 );
	for(int i = 1 ; i <= N ; ++ i)
		sum[i] = sum[i - 1] + a[i];
	int j = 2 , ret = 0;
	for(int i = 1 ; i <= N ; ){
		long long base = sum[i];
		while( j <= N && 2LL * base >= a[j] )
			base += a[j ++ ];
		if( j == N + 1 ){
			ret = N - i + 1;
			break;
		}
		i = j ;
		++ j;
	}
	printf( "%d\n" , ret );
	return 0;
}

Measured memory_bytes: 1408
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG //FOR THE DEBUG! COMMENT OUT THIS WHEN SUBMITTING!
#endif
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
//#include <unordered_set> //unordered_set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
//It is so troublesome that I include bits/stdc++.h !
using namespace std;

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 long long INF = 10010010010010;
const long long MOD = 1000000007;
typedef pair<int,int> P;

//Solve N^M. This, mod_pow use Iterative Square Method.
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}

long long gcd(long long a, long long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
    return a / gcd(a, b) * b ;
}

int main() {
    long long A,B,C,D;cin >> A >> B >> C >> D;
    long long T;cin >> T;
    if(B <= D){
        cout << "NO" << endl;
        return 0;
    }
    long long can = (B-D)*T;
    if(abs(A-C) <= can){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }
}


Measured memory_bytes: 3636
#include<iostream>
using namespace std;
int main()
{
    int a,b,k;
    cin>>a>>b;
    k=a+b;
    if(k%2==0)
    {
        cout<<k/2<<endl;
    }
    else
    {
        cout<<"IMPOSSIBLE"<<endl;
        
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1000000007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define rep(i, n) for(ll i=0; i<(ll)(n); i++)
#define repd(i, n) for(ll i=n-1; 0<=i; i--)
#define FOR(i, a, b) for(ll i=a; i<(ll)(b); i++)
#define FORD(i, a, b) for(ll i=b-1; (ll)(a)<=i; i--)
#define ALL(x) x.begin(), x.end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

ll calc(ll x){
    ll tar=x, pc=0;
    if(!tar) return 0;
    while(0<tar){
        if(tar%2) pc += 1;
        tar /= 2;
    }
    
    return calc(x%pc)+1;
}

int main(){
    ll n;   cin >> n;
    vector<ll> v(n);
    ll pc=0;
    rep(i, n){
        char x;   cin >> x;
        v[i] = x-'0';
        pc += v[i];
    }    
    vector<ll> res(n, 0);
    rep(bit, 2){
        ll tar = pc;
        if(bit) tar--;
        else tar++;
        if(tar<=0) continue;
        ll r=0;
        rep(i, n){
            r = r*2%tar;
            r += v[i];
        }
        ll dig=1;
        repd(i, n){
            if(bit==v[i]){
                ll nr = r;
                if(!bit) nr += dig;
                else nr -= dig;
                nr = ((nr%tar)+tar)%tar;   
                res[i] = calc(nr)+1;
            }    
            dig = dig*2%tar;
        }
    }
    
    rep(i, n) cout << res[i] << endl;
}


Measured memory_bytes: 6320
#include<bits/stdc++.h>
    using namespace std;
     int a[100];
    int main()
    {
           string s;
          cin>>s;
          for(int i=0;i<s.size();i++)
         {
               a[s[i] - 96] ++;
         }

          for(int i=0;i<s.size();i++)
         {
               if(a[i] >1)
                    {cout<<"no"<<endl;return 0;}
         }
        cout<<"yes"<<endl;

        return 0;
    }


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

using namespace std;
typedef long long ll;
typedef pair <ll, ll> l_l;
typedef pair<int, int> i_i;

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

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

# define EPS (1e-7)
# define INF (1e9)
# define PI (acos(-1))
//const ll mod = 1000000007;

int N;
vector<int> A, tmp_A;

int main() {
    cin >> N;
    for (int i = 0; i < N; ++i) {
        int a;
        cin >> a;
        A.push_back(a);
        tmp_A.push_back(a);
    }
    sort(A.begin(), A.end(), greater<int>());
    for (int i = 0; i < N; ++i) {
        if (tmp_A[i] != A[0]) {
            cout << A[0] << endl;
        } else {
            cout << A[1] << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3436
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.regex.Pattern;

public class Main {
    public void solve(BufferedReader stdin, PrintWriter stdout) throws NumberFormatException, IOException {
        int n = Integer.parseInt(stdin.readLine());
        int[] d = Pattern.compile(" ").splitAsStream(stdin.readLine()).mapToInt(Integer::parseInt).toArray();

        int ans = 0;
        for (int i = 0; i < n; i++) {
            for (int j = i + 1; j < n; j++) {
                ans += d[i] * d[j];
            }
        }
        stdout.println(ans);
    }

    public static void main(String[] args) throws NumberFormatException, IOException {
        BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter stdout = new PrintWriter(System.out, false);
        new Main().solve(stdin, stdout);
        stdout.flush();
    }
}


Measured memory_bytes: 29136
#include "bits/stdc++.h"
using namespace std;

#define REMNUM 1000000007

// x+y
static inline long modadd(long x, long y) {
  return (long)((long long)(x + y) % REMNUM);
}

// x*y
static inline long modmul(long x, long y) {
  return (long)(((long long)(x * y)) % REMNUM);
}

// x^y
static long modpow(long x, long y) {
  long res = 1;
  while (y > 0) {
    if (y & 1) {
      res = modmul(res, x);
    }
    x = modmul(x, x);
    y >>= 1;
  }

  return res;
}

static inline long modinv(long x) {
  return modpow(x, REMNUM - 2);
}

// x/y
static inline long moddiv(long x, long y) { return modmul(x, modinv(y)); }

// xCy => x*(x-1)*...*(x-y+1)/y*(y-1)*...*1
static long combination(long x, long y) {
  long divided = 1;
  long divisor = 1;

  for (int i = 0; i < y; i++) {
    divided = modmul(divided, (x - i));
    divisor = modmul(divisor, (y - i));
  }

  return moddiv(divided, divisor);
}

int main(int argc, char **argv) {
  long N, M, K;

  cin >> N >> M >> K;

  long comb = combination((modmul(N, M) - 2), (K - 2));

  long xsum = 0, xfixed;
  for (long d = 1; d < M; d++) {
    xfixed = modmul(comb, d);
    xfixed = modmul(modmul(N, N), xfixed);
    xfixed = modmul((M - d), xfixed);
    xsum = modadd(xsum, xfixed);
  }

  long ysum = 0, yfixed;
  for (long d = 1; d < N; d++) {
    yfixed = modmul(comb, d);
    yfixed = modmul(modmul(M, M), yfixed);
    yfixed = modmul((N - d), yfixed);
    ysum = modadd(ysum, yfixed);
  }

  cout << modadd(xsum, ysum) << endl;

  return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
ll inf =  1e9;


int main(){
 ll n;cin>>n;
 ll s = 0;
 for(ll i=1;i<=n;i++){
  if( i%3 != 0 && i%5 != 0 ) s += i;
 }
 cout<<s<<endl;
    return 0;
}


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

int main() {
    int n,x;
    int ans = 0;
    cin >> n >> x;
    vector<int> d(n+1);
    d.at(0) = 0;
    for(int i = 0; i < n; i++){
        int buf;
        cin >> buf;
        d.at(i+1) = d.at(i) + buf;
    }
    for(int i = 0; i < n+1; i++){
        if(d.at(i) <= x){
            ans++;
        }
    }
    cout << ans << endl;
}


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

int main(){

    int n; cin >> n;
    long long x = 1, y = 1;
    for (size_t i = 0; i < n; ++i) {
        int t, a;
        cin >> t >> a;
        long long n = max((x + t - 1)/t, (y + a - 1)/a);
        x = n * t;
        y = n * a;
    }
    cout << x + y;
    return 0;
}

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


int main() {
  string s;
  int a;
  cin >> a;
  cin >> s;

  if (a >= 3200){
    cout << s;
  } else {
    cout << "red";
  }
    cout <<endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>

int source[500][500] = {};

void copy_array(int a[],int b[],int m){
    for(int i=0;i<m;i++){
        b[i] = a[i];
    }
}

bool check(int n,int m,int sum[]){
    for(int j=0;j<m;j++){
        if(sum[j] %2 == 1) return false;
    }
    //std::cout << "      ";
    /*for(int j=0;j<m;j++){
        std::cout << sum[j] << ' ';
    }
    std::cout << '\n';
     */
    return true;
}

bool sum_calc(int f_num,int f_pos,int m,int n,int pri_sum[]){
    //std::cout << "再起\n";
    int sum[500] = {};
    //std::cout << "f_num=" << f_num << '\n';
    for(int i=f_pos;i<n-f_num+1;i++){
        //std::cout << "f_num=" << f_num << "  f_pos=" << i << '\n';
        copy_array(pri_sum,sum,m);
        
        for(int j=0;j<m;j++){
            sum[j] -= source[i][j];
        }
        
        f_num--;
        if(f_num==0){
            //std::cout << "      f_num=0\n";
            if(check(n,m,sum)){
                return true;
            }else{
                //std::cout << "失敗した\n";
                f_num++;
            }
        }else{
            if(sum_calc(f_num,i+1,m,n,sum)){
                return true;
            }else{
                f_num++;
            }
        }
    }
    //std::cout << "終了\n";
    return false;
}

void to_int(char s[],int i){
    int j=0;
    while(s[j] != '\0'){
        if(s[j] == '0'){
            source[i][j++] = 0;
        }else{
            source[i][j++] = 1;
        }
    }
}

int search(int n,int m,int sum[]){
    for(int f_num=1;f_num<n;f_num++){
        //std::cout << "f_num=" << f_num << '\n';
        if(sum_calc(f_num,0,m,n,sum)) return f_num;
    }
    return n;
}

int main(){
    int n,m;
    while(1){
        std::cin >> n >> m;
        if(n==0&&m==0) return 0;
        //std::cout << "n:" << n <<" m:" << m << '\n';
        char s[500];
        for(int i=0;i<n;i++){
            std::cin >> s ;
            to_int(s,i);
        }
        
        /*for(int i=0;i<n;i++){
            for(int j=0;j<m;j++){
                std::cout << source[i][j] << ' ';
            }
            std::cout << '\n';
        }
        */
        int sum[500] = {};
        for(int i=0;i<n;i++){
            for(int j=0;j<m;j++){
                sum[j] += source[i][j];
            }
        }
        
        if(check(n,m,sum)){
            std::cout << /*"ans=" <<*/ n << '\n';
        }else{
            int ans=n-search(n,m,sum);
            std::cout << /*"ans=" <<*/ ans << '\n';
        }
        //std::cout << '\n';
    }
    /*for(int j=0;j<m;j++){
     std::cout << sum[j] << ' ' ;
     }
     std::cout << '\n';
     */
    
    return 0;
}



Measured memory_bytes: 4036
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<math.h>
#include<algorithm>
#include<iomanip>
#include<list>
#include<bitset>
#include<sstream>
using namespace std;

int main() {

	long long N, X, M;
	cin >> N >> X >> M;

	long long sum = 0;
	long long cnt = 0;

	vector<long long> v(M + 1, 0);
	vector<long long> c(M + 1, 0);

	bool jdg = false;
	long long A1, A2;
	A1 = X;

	for (long long i = 1; i <= N; i++) {
		sum += A1;
		cnt += 1;
		if (v[A1] == 0) {
			v[A1] = sum;
			c[A1] = cnt;
		}
		else {
			jdg = true;
			break;
		}
		A2 = A1 % M;
		A2 = A2 * A2;
		A1 = A2 % M;
		if (A1 == 0) {
			break;
		}
	}

	if (jdg == true) {
		long long val = sum - v[A1];
		long long dal = cnt - c[A1];

		long long b = (N - cnt) / dal;
		long long bb = (N - cnt) % dal;

		sum += b * val;

		A2 = A1 % M;
		A2 = A2 * A2;
		A1 = A2 % M;

		for (long long i = 1; i <= bb; i++) {
			sum += A1;
			cnt += 1;
			A2 = A1 % M;
			A2 = A2 * A2;
			A1 = A2 % M;
		}
	}
	
	cout << sum << endl;

	return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

typedef pair<int, int> ii;
typedef pair<ll, ll> pll;

int main( int argc, char *argv[] ) {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	ll n, d, x, tmp;

	cin >> n >> d >> x;
	d--;
	for ( int i = 0 ; i < n ; i++ ){
		cin >> tmp;
		x += 1 + d / tmp;
	}

	cout << x << "\n";
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <functional>
#include <utility>
#include <cctype>
#include <fstream>
#include <cstring>

using namespace std;

#define ll long long
#define MOD 1000000007
#define INF 2000000000
#define LINF 9000000000000000000
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define du(x) cout<<#x<<'='<<x<<endl
#define du2(x,y) cout<<#x<<'='<<x<<' '<<#y<<'='<<y<<'\n'<<endl
#define du3(x,y,z) cout<<#x<<'='<<x<<' '<<#y<<'='<<y<<' '<<#z<<'='<<z<<'\n'<<endl
#define darr(arr,n) rep(i,(n-arr)){cout<<*(arr+i)<<' ';}cout<<endl
#define ddarr(arr,a,b) rep(i,a){rep(j,b){cout<<*(arr+i*b+j)<<' ';}cout<<endl;}
#define ddd ifstream in("Text.txt");cin.rdbuf(in.rdbuf());

string S[10000];

int main() {
    int N;
    cin >> N;
    rep(i, N)cin >> S[i];

    int AB = 0;
    rep(i, N) {
        rep(j, S[i].size() - 1) {
            if (S[i][j] == 'A'&&S[i][j + 1] == 'B')AB++;
        }
    }

    int B0 = 0, A1 = 0, B0A1 = 0;
    rep(i, N) {
        if (S[i][0] == 'B'&& S[i][S[i].size() - 1] == 'A') {
            B0A1++;
        }
        else {
            if (S[i][0] == 'B')B0++;
            if (S[i][S[i].size() - 1] == 'A')A1++;
        }
    }
    if (B0A1 == 0)cout << min(A1, B0) + AB << endl;
    else {
        if (A1 + B0 == 0)cout << B0A1 - 1 + A1 + AB << endl;
        else cout << B0A1 + min(A1, B0) + AB << endl;
    }

}

Measured memory_bytes: 768
#include <iostream>
#define llint long long

using namespace std;

int N, K;
int A[100005], B[100005];

llint buy(int filter)
{
	llint ret = 0;
	for(int i = 0; i < N; i++){
		if( (A[i] | filter) == filter) ret += B[i];
	}
	return ret;
}

int main(void)
{
	cin >> N >> K;
	for(int i = 0; i < N; i++){
		cin >> A[i] >> B[i];
	}
	
	llint ans = 0;
	int filter = 0;
	
	for(int i = 30; i >= 0; i--){
		if(K & (1 << i)){
			ans = max(ans, buy(filter + (1 << i) - 1));
			filter += (1 << i);
		}
	}
	ans = max(ans, buy(K));
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
# include <bits/stdc++.h>
typedef long long lint;
using namespace std;

lint gcd(lint x, lint y) {
  if(x == 0) { return y; }
  else { return gcd(y%x,x); }
}

lint lcm(lint x, lint y) { return x/gcd(x,y)*y; }

lint C(lint n, lint k) {
  if(n == k) { return 1; }
  else if(n < k) { return 0; }
  else if(k == 0) { return 1; }
  else if(k == 1) { return n; }
  else return C(n-1,k-1) + C(n-1,k);
}

lint P(lint n, lint k) {
  if(k == 1) { return n; }
  return (n*(P(n-1,k-1)%1000000007)%1000000007);
}


int main() {
  int x,y; cin >> x >> y;
  
  for(int i=0;i<=x;i++) {
    if(2*i+4*(x-i) == y) {
      cout << "Yes" << endl;
      return 0;
    }
  } // 
  
  cout <<"No" << endl;
  return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using s64 = int64_t;
using u64 = uint64_t;

int main() {
	u64 K;
	cin >> K;
	
	u64 ans = 1;
	u64 t = 0;
	
	while(t < K) {
		u64 tans = ans;
		u64 sketa = 0;
		
		while(tans > 0) {
			if(tans < 10) {
				t++;
				ans++;
				break;
			}
			
			s64 keta1 = tans % 10;
			s64 keta2 = (tans % 100) / 10;
			
			if(abs(keta1 - keta2) > 1) { 
				ans = ans - (ans % (u64)pow(10, sketa)) + pow(10, sketa);
				break;
			} else {
				tans /= 10;
				sketa++;
			}
		}
	}

	cout << ans - 1;;
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1000000000000000000

using namespace std;

int main(void){
  ll n, m, k;
  cin >> n >> m >> k;
  
  vector<ll> a(n);
  for (int i = 0; i < n; i++){
    cin >> a[i];
  }
  vector<ll> suma(n + 1, 0);
  for (int i = 0; i < n; i++){
    suma[i+1] = suma[i] + a[i];
  }
  vector<ll> b(m);
  for (int i = 0; i < m; i++){
    cin >> b[i];
  }
  vector<ll> sumb(m + 1, 0);
  for (int i = 0; i < m; i++){
    sumb[i+1] = sumb[i] + b[i];
  }

  ll ans = 0;
  for (int i = 0; i < n + 1; i++){
    if (suma[i] > k)
      break;

    ll c = upper_bound(sumb.begin(), sumb.end(), k-suma[i]) - sumb.begin() - 1;
    ans = max(ans, i + c);
  }
  cout << ans << endl;
  

  return 0;
}


Measured memory_bytes: 9596
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);
        int n = Integer.parseInt( in.nextLine() );
        String[] params = in.nextLine().split(" ");
        long[] hs = new long[n];
        for( int i = 0 ; i < n ; i++ ){
            hs[i] = Long.parseLong( params[i]);
        }

        int max = 0;
        int count = 0;
        for( int i = 0 ; i < n - 1 ; i++ ){
            if( hs[i] >= hs[ i+ 1 ] ){
                count++;
            }
            else {
                if( max < count ){
                    max = count;
                }
                count = 0;
            }
            if( i + 1 == n - 1 ){
                if( max < count ){
                    max = count;
                }
            }
        }

        System.out.println(max);

    }

}



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

int main() {
  int A, B, C;
  cin >> A >> B >> C;

  int ans = A * 10 + B + C;
  ans = max(ans, A + B * 10 + C);
  ans = max(ans, A + B + C * 10);
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
#include <cassert>

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
using namespace std;

int main() {
    int N, M;
    cin >> N >> M;
    //priority_queue<int, vector<int>, std::greater<int>> q;
    priority_queue<int> q;
    rep(i, N) {
        int A;
        cin >> A;
        q.push(A);
    }

    rep(i, M) {
        int X = q.top();
//        cout << X << " to " << X/2 << endl;
        q.pop();
        q.push(X/2);
    }
    uint64_t ret = 0;
    rep(i, N) {
        ret += q.top();
        q.pop();
    }
    cout << ret << endl;

    return 0;
}



Measured memory_bytes: 3360
import java.util.Scanner;
public class Main {
	int T;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		Main tr = new Main();
		tr.test(sc);
		sc.close();
	}
	int N;

	void test(Scanner sc){
		long A = sc.nextLong();
		long B = sc.nextLong();
		long C = sc.nextLong();
		long K = sc.nextLong();
		long ans = -1;
		if(K%2==1){
			if(Math.abs(B-A) <= Math.pow(10, 18)){
				ans = B-A;
				System.out.println(ans);
				return;				
			}
		}else{
			if(Math.abs(A-B) <= Math.pow(10, 18)){
				ans = A-B;
				System.out.println(ans);
				return;
			}
		}

		System.out.println("Unfair");
	}
}


Measured memory_bytes: 21844
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#define ele int
using namespace std;
#define maxn 200010
const ele INF=1e9;
struct edge{
	ele v;
	edge *nxt;
}ep[maxn<<1],*ecnt;
ele n,r,d[maxn],f[maxn];
edge *h[maxn];
inline void addedge(ele u,ele v){
	edge *p=ecnt++;
	p->v=v; p->nxt=h[u];
	h[u]=p;
}
void dfs(ele p,ele i,ele B){
	vector<ele> lst;
	for (edge *j=h[i]; j; j=j->nxt)
		if (j->v!=p){
			dfs(i,j->v,B);
			lst.push_back(f[j->v]);
		}
	if (lst.size()%2==0) lst.push_back(0);
	sort(lst.begin(),lst.end());
	f[i]=INF;
	for (int r=0; r<lst.size(); ++r){
		ele u=0,v=lst.size()-1;
		bool flag=true;
		while (u<v){
			if (u==r) ++u;
			if (v==r) --v;
			if (u<v && lst[u]+lst[v]>B){ flag=false; break; }
			++u; --v;
		}
		if (flag){ f[i]=lst[r]+1; break; }
	}
}
inline bool test(ele B){
	dfs(-1,r,B);
	return f[r]<=B+1;
}
int main(){
	scanf("%d",&n);
	ecnt=ep; memset(h,0,sizeof(h)); memset(d,0,sizeof(d));
	for (int i=0; i<n-1; ++i){
		ele x,y;
		scanf("%d%d",&x,&y); --x,--y;
		addedge(x,y); addedge(y,x);
		++d[x]; ++d[y];
	}
	ele cnt=0;
	for (int i=0; i<n; ++i)
		if (d[i]&1) ++cnt,r=i;
	ele L=0,R=n-1;
	while (R-L>1){
		ele mid=(L+R)>>1;
		if (test(mid)) R=mid; else L=mid;
	}
	printf("%d %d\n",cnt/2,R);
	return 0;
}

Measured memory_bytes: 17664
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
  int a[5];
  rep(i,5) cin>>a[i];
  int k; cin>>k;
  int memo=0;
  rep(i,5)rep(j,5) if(abs(a[i]-a[j])>k)memo++;
  cout<<(memo>0? ":(":"Yay!")<<endl;
}


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

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

class BinaryIndexedTree {
    vector<int64_t> container;

public:
    BinaryIndexedTree(size_t size)
        : container(size + 1)
    {
        fill(container.begin(), container.end(), 0);
    }
    void add(size_t i, int64_t v)
    {
        size_t idx = i + 1;
        while (idx < container.size()) {
            container[idx] += v;
            idx += idx & -idx;
        }
    }
    int64_t find(size_t i)
    {
        size_t idx = i;

        int64_t result = 0;
        while (idx != 0) {
            result = container[idx] + result;
            idx -= idx & -idx;
        }
        return result;
    }
};

using L = tuple<int, int, int>;
using P = tuple<double, size_t>;

const double INF = 1e9;

int main()
{
    cout << fixed << setprecision(10);

    vector<L> ys;

    int n;
    cin >> n;
    const int half = ((n * (n - 1) / 2) + 1) / 2;
    rep(i, n)
    {
        int a, b, c;
        cin >> a >> b >> c;
        ys.push_back(make_tuple(a, b, c));
    }

    double result[2];
    rep(i, 2)
    {
        sort(ys.begin(), ys.end(), [](const L& lh, const L& rh) {
            int la, lb, ra, rb;
            tie(la, lb, ignore) = lh;
            tie(ra, rb, ignore) = rh;

            return -(double)la / lb > -(double)ra / rb;
        });

        double lb = -INF, ub = INF;
        while (ub - lb >= 1e-10 && ub - lb >= 1e-10 * abs(ub / 2 + lb / 2)) {
            const double mid = ub / 2 + lb / 2;

            vector<P> tmp;
            tmp.reserve(ys.size());
            rep(i, ys.size())
            {
                int a, b, c;
                tie(a, b, c) = ys[i];
                tmp.push_back(make_tuple((c - a * mid) / b, i));
            }
            sort(tmp.begin(), tmp.end());

            int64_t intersection = 0;
            BinaryIndexedTree bit(tmp.size());
            rep(i, tmp.size())
            {
                size_t j;
                tie(ignore, j) = tmp[i];
                intersection += bit.find(tmp.size()) - bit.find(j + 1);
                bit.add(j, 1);
            }

            (intersection >= half ? ub : lb)
                = mid;
        }
        result[i] = ub;

        for (L& l : ys) {
            swap(get<0>(l), get<1>(l));
        }
    }
    cout << result[0] << " " << result[1] << endl;

    return 0;
}

Measured memory_bytes: 1668
#!/mnt/c/Users/moiki/bash/env/bin/python
N = int(input())
p = list(map(float, input().split()))

import numpy as np
dp = np.full(N+1, 0, dtype=np.float64)
dp[0] = 1
n_p = np.array(p)

for i in range(N):
    tmp      = np.zeros_like(dp)
    tmp[1:]  = dp[:-1] * n_p[i]
    tmp[:-1]+= dp[:-1] * (1-n_p[i])
    dp = tmp

ans = np.sum(dp[N//2+1:])
print(ans)

# for i in range(1, 1+N): # timestep
#     for j in range(0, 0+i): # pos
#         dp[j] = dp[
#     # kdp[:i] a

# suml = [[1 for x in range(round+1)] for round in range(N+1)]
# 
# for e,p in enumerate(P):
#     for (es, s),_ in zip(enumerate(suml[e]), range(e+1)):
# 
#         if (es == 0):
#             suml[e+1][es]   = suml[e][es] * (1-p)
#         else:
#             suml[e+1][es]   += suml[e][es] * (1-p)
# 
#         suml[e+1][es+1] = suml[e][es] * p
# 
# 
# sumA = suml[N][:len(suml[N])//2-1:-1]
# sumA = sum(sumA)
# print(sumA)


Measured memory_bytes: 12600
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const ll MOD = 1e9 + 7;
const int INF = 100100100;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl

int N; int L[4000];

void input(){
  cin >> N;
  REP(i, N) cin >> L[i];
}

/* TLE
void solve(){
  int res = 0;
  REP(i, N) REP(j, i) REP(k, j){
    if(L[i] < L[j] + L[k] && L[j] < L[k] + L[i] && L[k] < L[i] + L[j]){
      res++;
    }
  }
  cout << res << endl;
}
*/

// Lをソート i > j > k で i と j をfor、 k を二分探索 O(N^2 logN)
void solve(){
  vector<int> v(N);
  REP(i, N) v[i] = L[i];
  int ans = 0;
  sort(v.begin(),v.end());
  REP(i, N) REP(j, i){
    auto itr = upper_bound(v.begin(), v.end(), v[i] - v[j]);
    ll index = itr - v.begin();
    ans += ((j > index) ? (j - index) : 0);
    /*
    debug(i);
    debug(j);
    debug(index);
    debug(ans);
    */
  }
  cout << ans << endl;
}

int main(){
  input();
  solve();
}

Measured memory_bytes: 256
package main

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

func exec(stdin *Stdin, stdout *Stdout) {
	h := stdin.ReadInt()
	w := stdin.ReadInt()
	n := stdin.ReadInt()

	x := Max(h, w)
	if n%x == 0 {
		stdout.Println(n / x)
	} else {
		stdout.Println(n/x + 1)
	}
}

func Max(a ...int) int {
	v := a[0]
	for i := 1; i < len(a); i++ {
		if v < a[i] {
			v = a[i]
		}
	}
	return v
}

func main() {
	stdout := NewStdout()
	defer stdout.Flush()
	exec(NewStdin(bufio.ScanWords), stdout)
}

type Stdin struct {
	stdin *bufio.Scanner
}

func NewStdin(split bufio.SplitFunc) *Stdin {
	s := Stdin{bufio.NewScanner(os.Stdin)}
	s.stdin.Split(split)
	s.stdin.Buffer(make([]byte, bufio.MaxScanTokenSize), int(math.MaxInt32))
	return &s
}

func (s *Stdin) Read() string {
	s.stdin.Scan()
	return s.stdin.Text()
}

func (s *Stdin) ReadInt() int {
	n, _ := strconv.Atoi(s.Read())
	return n
}

func (s *Stdin) ReadFloat64() float64 {
	n, _ := strconv.ParseFloat(s.Read(), 64)
	return n
}

type Stdout struct {
	stdout *bufio.Writer
}

func NewStdout() *Stdout {
	return &Stdout{bufio.NewWriter(os.Stdout)}
}

func (s *Stdout) Flush() {
	s.stdout.Flush()
}

func (s *Stdout) Println(a ...interface{}) {
	fmt.Fprintln(s.stdout, a...)
}


Measured memory_bytes: 640
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, *A = map(int, read().split())

U = 10 ** 18
p = 1
for x in A:
    p *= x
    if p > U:
        p = U + 1

if p > U:
    print(-1)
else:
    print(p)

Measured memory_bytes: 19932
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

typedef long double ld;

#ifdef DEBUG
#define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#else
#define eprintf(...) ;
#endif

#define sz(x) ((int) (x).size())
#define TASK "text"

const int inf = (int) 1.01e9;
const long long infll = (long long) 1.01e18;
const ld eps = 1e-9;
const ld pi = acos((ld) -1);

mt19937 mrand(random_device{} ()); 

int rnd(int x) {
  return mrand() % x;
}

void precalc() {
}

const int maxn = 105;
int n;
int a[maxn];

int read() {
  if (scanf("%d", &n) < 1) {
    return false;
  }
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  return true;
}

void solve() {
  int res = 0;
  for (int j = 0; j < n;) {
    int i = j;
    while (j < n && a[i] == a[j]) {
      j++;
    }
    res += (j - i) / 2;
  }
  printf("%d\n", res);
}

int main() {
  precalc();
#ifdef DEBUG
  assert(freopen(TASK ".in", "r", stdin));
  assert(freopen(TASK ".out", "w", stdout));
#endif
  while (read()) {
    solve();
#ifdef DEBUG
    eprintf("Time %.2f\n", (double) clock() / CLOCKS_PER_SEC);
#endif
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
	int a,b,c;
	char op;
	do{
		cin >> a >> op >>b;
		if(op=='+')
			c=a+b;
		else if(op == '-')
			c=a-b;
		else if(op == '*')
			c=a*b;
		else if(op == '/')
			c=a/b;
		else
			break;
		cout << c <<"\n";
	}while(op!='?');
}


Measured memory_bytes: 3116
from itertools import combinations
from bisect import bisect_left

N = int(input())
L = sorted(map(int, input().split()))

counter = 0
for i in range(N-2):
    for j in range(i+1, N-1):
        upper_bound = bisect_left(L, L[i] + L[j], j+1, N)
        counter += upper_bound - (j+1)
print(counter)

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

const int MOD = 1e9+7;

int modPow(ll a, ll n, ll mod) {
  if(n == 0) return 1;
  if(n == 1) return a % mod;
  if(n % 2 == 1) return (a * modPow(a, n-1, mod)) % mod;
  ll t = modPow(a, n/2, mod);
  return (t*t) % mod;
}

int main(){
  int n;
  cin >> n;
  ll ans = modPow(10, n, MOD);
  ans -= (modPow(9, n, MOD) *2) % MOD;
  ans += modPow(8, n, MOD);
  ans %= MOD;
  cout << (ans+MOD)%MOD << endl;
  return 0;
}

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

typedef long long int ll;

#define sc1(a) scanf("%lld",&a)
#define sc2(a,b) scanf("%lld %lld",&a,&b)
#define MAX(a,b) (a>b?a:b)

int main()
{
    ll a,b,c,d,ac,ad,bc,bd;
    ll max1;
    cin>>a>>b>>c>>d;

    ac=a*c;
    ad=a*d;
    bc=b*c;
    bd=b*d;

    max1=max((max(ac,ad)),(max(bc,bd)));

    cout<< max1 <<endl;
}


Measured memory_bytes: 3580
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(begin, i, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    ll X, Y, Z;
    cin >> X >> Y >> Z;
    X -= Z;
    ll ans = 0;
    while (X >= Y + Z)
    {
        X -= Y + Z;
        ans++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 3628
#include <stdio.h>
#include <string.h>

int main(void){
  int N,j=0;
  scanf("%d",&N);
  char S[N];
  scanf("%s",S);
  
  for(int i=0;i<N;i++){
    if(S[i]=='A'){
      if(S[i+1]=='B'){
        if(S[i+2]=='C'){
          j++;i=i+2;
        }
      }
    }
  }
  printf("%d\n",j);
    return 0;
  }
  
  
  

Measured memory_bytes: 128
#include <iostream>
#include <vector>

int main(){
    int k;
    std::cin >> k;
    std::vector<long long> vec = {1,2,3,4,5,6,7,8,9};
    if(k <= 9){
        std::cout << k << std::endl;
        return 0;
    }
    int count1 = 0;
    int count2 = 9;
    while(1){
        std::vector<long long> old = vec;
        for(int i = count1; i < old.size(); i++){
            long long item = old[i];
            count1++;
            for(int i = -1; i <= 1; i++){
                long long t = item%10 + i;
                if(t == -1 || t == 10) continue;
                vec.push_back(10*item+t);
                if(++count2==k){
                    std::cout << vec[k-1] << std::endl;
                    return 0;
                }
            }
        }
    }
}


Measured memory_bytes: 2120
#include <iostream>
#include <cmath>
#include <iomanip>
#include <algorithm>
#include <map>
#include <string>
#include <cstring>
#include <vector>
using namespace std;

#define i64 int64_t
void agc13c()
{
  i64 n, l, t;
  cin >> n >> l >> t;
  i64 x[n], w[n];
  i64 ans[n];
  i64 count = 0;
  for (i64 i = 0; i < n; i++)
  {
    cin >> x[i] >> w[i];
    if (w[i] == 1)
      ans[i] = (x[i] + t) % l;
    else
      ans[i] = ((x[i] - t) + t * l) % l;
  }
  for (i64 i = 1; i < n; i++)
  {
    if (w[0] != w[i])
    {
      if (w[0] == 1)
      {
        if (2 * t - (x[i] - x[0] - 1) < 0)
          continue;
        else
          count += 1 + (2 * t - (x[i] - x[0])) / l;
      }
      else
      {
        if (2 * t - l + (x[i] - x[0] + 1) < 0)
          continue;
        else
          count += 1 + (2 * t - l + (x[i] - x[0])) / l;
      }
      count = count % n;
    }
  }
  if (w[0] == 2)
  {
    count = (n - count) % n;
  }

  i64 ans_f = ans[0];
  sort(ans, ans + n);
  i64 index = 0;
  for (i64 i = 0; i < n; i++)
  {
    if (ans[i] == ans_f)
    {
      index = i;
      if (w[0] == 2)
        break;
    }
  }
  i64 res[n];
  for (i64 i = 0; i < n; i++)
  {
    res[(count + i) % n] = ans[(index + i) % n];
  }
  for (i64 i = 0; i < n; i++)
    cout << res[i] << endl;
}

int main(void)
{
  agc13c();
  return 0;
}


Measured memory_bytes: 4352
A, B, C, D, E, F = map(int, input().split())
water, k, l = set(), 1, 1
while k * A * 100 <= F:
    water.add(k * A * 100)
    k += 1
while l * B * 100 <= F:
    water.add(l * B * 100)
    l += 1
for i in range(1, k):
    for j in range(1, l):
        if (i * A + j * B) * 100 <= F:
            water.add((i * A + j * B) * 100)
        else:
            break

water = list(water)
suger = []
concentration = []
for i in range(len(water)):
    suger_limit = min(water[i] // 100 * E, F - water[i])
    temp, k = 0, 0
    while k * C <= suger_limit:
        l = (suger_limit - k * C) // D
        while l >= 0:
            if k * C + l * D > temp:
                temp =  k * C + l * D 
            l -= 1
        k += 1
    suger.append(temp)
    concentration.append(suger[i] / (water[i] + suger[i]))

i = concentration.index(max(concentration))
print(water[i] + suger[i], suger[i])

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
	string a[3]={"Sunny","Cloudy","Rainy"};
	string ss;
	cin>>ss;
	if(ss==a[0]) cout<<a[1];
	if(ss==a[1]) cout<<a[2];
	if(ss==a[2]) cout<<a[0];
	return 0;
}

Measured memory_bytes: 256
/* C - Marks */

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

int main(){
  int N, K, j = 0;
  cin >> N >> K;
  vector<int> A(N);
  for(int i = 0; i < N; i++){
    cin >> A.at(i);
  }
  for(int i = K; i < N; i++){
    if(A.at(j++) < A.at(i)){
      cout << "Yes" << endl;
    }else{
      cout << "No" << endl;
    }
  }
}


Measured memory_bytes: 3996
# coding: utf-8
# Your code here!
import sys
read = sys.stdin.read
readline = sys.stdin.readline

n,*a = map(int, read().split())

m = 1000
s = 0

for i in range(n):
    if i+1 < n:
        if a[i] < a[i+1]:
            s += m//a[i]
            m %= a[i]
        else:
            m += s*a[i]
            s = 0
    else:
        m += s*a[i]
        s = 0
        
print(m)        




Measured memory_bytes: 9184
A = input()
B = input()
C = input()
n = A[0]
A = A[1:]
while True:
  if n == "a":
    if len(A) == 0:
      print("A")
      break
    n = A[0]
    A = A[1:]

  elif n == "b":
    if len(B) == 0:
      print("B") 
      break
    n = B[0]
    B = B[1:]
  else:
    if len(C) == 0:
      print("C")
      break
    n = C[0]
    C = C[1:]
            
            
            
            
            
            
      
     
  

Measured memory_bytes: 8952
#include<iostream>
#include<vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <limits>
#include <map>
#include <bitset>
#include <iomanip>

#define rep(i,n) for(int (i) = 0; (i)<(n); (i)++)
#define FOR(i,s,e) for(int (i) = (s); (i)<(e); (i)++)
#define vecall(itr,vec) for(auto (itr) = (vec).begin(); (itr) != (vec).end(); (itr)++)
#define vecshow(vec) for(auto itr = (vec).begin(); itr != (vec).end(); itr++)cout << *itr << " ";

using namespace std;
using p = pair<int, int>;
using ll = long long;

int gcd(int a, int b) {
	int l = max(a, b);
	int s = min(a, b);
	while (l * s != 0) {
		int tmp = s;
		s = l % s;
		l = tmp;
	}

	return l;
}

vector<vector<int>> path;

int main() {
	string s, t;
	int count = 0;
	cin >> s;
	cin >> t;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] != t[i])count++;
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 3912
#include <stdio.h>
int main(){
int tou,H,W,hito,n,i,j,k,m=0;
int p[4][3][10]={0};
scanf("%d",&n);
for (m = 0; m < n; m++){
scanf("%d %d %d %d",&tou,&H,&W,&hito);
p[tou-1][H-1][W-1]=p[tou-1][H-1][W-1]+hito;
}
  for (k = 0; k < 3; k++){
    for (j = 0; j < 3; j++){ 
      for (i = 0; i < 10; i++){
   	 printf(" %d",p[k][j][i]);
      }  
      printf("\n");  
    }
    printf("####################\n");
  }
   
  for (j = 0; j < 3; j++){
    for (i = 0; i < 10; i++){
      printf(" %d",p[3][j][i]);
    }
    printf("\n");
  }
  return 0;
}


Measured memory_bytes: 2148
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(os.Stdout)

	h := getNextInt64(scanner)
	w := getNextInt64(scanner)

	n := getNextInt(scanner)
	imm := IntMapMap{}
	for i := 0; i < n; i++ {
		a := getNextInt(scanner)
		b := getNextInt(scanner)

		for y := -1; y < 2; y++ {
			for x := -1; x < 2; x++ {
				ay := a + y
				if ay <= 1 || ay >= int(h) {
					continue
				}
				bx := b + x
				if bx <= 1 || bx >= int(w) {
					continue
				}
				imm.increment(ay, bx)
			}
		}
	}

	var ans [10]int64
	ans[0] = (h - 2) * (w - 2)

	for _, im := range imm {
		for _, c := range im {
			ans[c]++
			ans[0]--
		}
	}
	for i := 0; i < 10; i++ {
		fmt.Fprintln(writer, ans[i])
	}

	writer.Flush()
}

// IntMap ...
type IntMap map[int]int

func (m IntMap) get(key int) int {
	if _, ok := m[key]; ok {
		return m[key]
	}
	return 0
}

func (m IntMap) set(key, n int) {
	if _, ok := m[key]; ok == false {
		m[key] = 0
	}
	m[key] = n
}

func (m IntMap) increment(key int) {
	if _, ok := m[key]; ok == false {
		m[key] = 0
	}
	m[key]++
}

// IntMapMap ...
type IntMapMap map[int]IntMap

func (m IntMapMap) get(key1, key2 int) int {
	if _, ok := m[key1][key2]; ok {
		return m[key1][key2]
	}
	return 0
}

func (m IntMapMap) set(key1, key2, n int) {
	if _, ok := m[key1]; ok == false {
		m[key1] = make(IntMap, 0)
	}
	m[key1].set(key2, n)
}

func (m IntMapMap) increment(key1, key2 int) {
	if _, ok := m[key1]; ok == false {
		m[key1] = make(IntMap, 0)
	}
	m[key1].increment(key2)
}


Measured memory_bytes: 93976
import sys

def II(): return int(input())
def MI(): return map(int,input().split())
def LI(): return list(map(int,input().split()))
def TI(): return tuple(map(int,input().split()))
def RN(N): return [input().strip() for i in range(N)]


def main():
    N = II()
    A = LI()
    numa = len(set(A))
    #print(numa)
        
    if numa == N:
        print("YES")
    else:
        print("NO")


if __name__ == "__main__":
	main()

Measured memory_bytes: 25424
#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;}

const int NM = 110;
const int WM = 1e5 + 10;

ll dp[NM][WM]; // iばんめまで 重さがxxを超えないように選択したときの，価値の最大値
ll weight[NM];
ll value[NM];

int main() {
    int n, w; cin >> n >> w;
    rep(i, n) {
        cin >> weight[i] >> value[i];
    }

    for(int i=0; i<n; i++) {
        for(int sum_w = 0; sum_w<=w; sum_w++) {
            // choose i
            if(sum_w - weight[i] >= 0) {
                chmax(dp[i+1][sum_w], dp[i][sum_w - weight[i]] + value[i]);
            }
            // not choose i
            chmax(dp[i+1][sum_w], dp[i][sum_w]);
        }
    }
    cout << dp[n][w] << endl;
}

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


void printLCS(string s1, string s2, int m, int n)
{
   int L[m+1][n+1];

   for (int i=0; i<=m; i++)
   {
     for (int j=0; j<=n; j++)
     {
       if(i==0||j==0)
         L[i][j]=0;
       else if (s1.at(i-1) == s2.at(j-1))
         L[i][j] = L[i-1][j-1] + 1;
       else
         L[i][j] = max(L[i-1][j], L[i][j-1]);
     }
   }

   int index = L[m][n];
   char LCS[index+1];
   LCS[index] = '\0';

   int i = m, j = n;
   while (i > 0 && j > 0)
   {

      if (s1.at(i-1) == s2.at(j-1))
      {
          LCS[index-1] = s1.at(i-1);
          i--; j--; index--;
      }
      else if (L[i-1][j] > L[i][j-1])
         i--;
      else
         j--;
   }
   cout<<LCS<<endl;


}

int main()
{
    string s1, s2;
    cin>>s1>>s2;

    printLCS(s1, s2, s1.length(), s2.length());
    return 0;
}


Measured memory_bytes: 35456
#include <cstdio>
#pragma warning(disable: 4996)
int H, W, r, cnt,  dir[4] = { 1, 0, -1, 0 }; char c[12][12], f[31], g[] = "RDLU";
void solve(int x, int y, int d, int e) {
	if (d == r) {
		for (int i = 0; i < r; i++) printf("%c", f[i]);
		printf("\n");
		return;
	}
	for (int i = 0; i < 4; i++) {
		if ((i + 2) % 4 == e) continue;
		int tx = x, ty = y;
		while (0 <= tx && tx < W && 0 <= ty && ty < H) {
			if (c[ty][tx] == 'o') {
				c[ty][tx] = '.'; f[d] = g[i];
				solve(tx, ty, d + 1, i);
				c[ty][tx] = 'o'; f[d] = 0;
				break;
			}
			tx += dir[i];
			ty += dir[i ^ 1];
		}
	}
}
int main() {
	scanf("%d%d", &H, &W);
	for (int i = 0; i < H; i++) scanf("%s", c[i]);
	int sy, sx, se;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			for (int k = 0; k < 4; k++) {
				if (c[i][j] == g[k]) {
					c[i][j] = '.';
					sy = i, sx = j, se = k;
				}
			}
			if (c[i][j] == 'o') r++;
		}
	}
	solve(sx, sy, 0, se);
	return 0;
}

Measured memory_bytes: 2684