akhauriyash/Code-Regression huggingface dataset:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

A, B, C = MAP()

if A == B == C and A != 1:
	print(-1)
	exit()
ans = 0
while A%2 == 0 and B%2 == 0 and C%2 == 0:
	A, B, C = (B+C)//2, (A+C)//2, (A+B)//2
	ans += 1
print(ans)


Measured memory_bytes: 5400
import java.util.Collections;
import java.util.LinkedList;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long x = Long.parseLong(sc.next());
        long y = Long.parseLong(sc.next());
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        int c = Integer.parseInt(sc.next());
        LinkedList<Long> p = new LinkedList<>();
        LinkedList<Long> q = new LinkedList<>();
        LinkedList<Long> r = new LinkedList<>();
        for (int i = 0; i < a; i++) {
            p.add(Long.parseLong(sc.next()));
        }
        for (int i = 0; i < b; i++) {
            q.add(Long.parseLong(sc.next()));
        }
        for (int i = 0; i < c; i++) {
            r.add(Long.parseLong(sc.next()));
        }
        Collections.sort(p);
        Collections.sort(q);
        int k = (int) (x + y);
        long ans = 0;
        for (int i = 0; i < x; i++) {
            r.add(p.pollLast());
        }
        for (int i = 0; i < y; i++) {
            r.add(q.pollLast());
        }
        Collections.sort(r);
        for (int i = 0; i < k; i++) {
            ans += r.pollLast();
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 74128
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.nextLine();
		String[] spl = s.split(" ");
		int R = Integer.parseInt(spl[0]);
		int G = Integer.parseInt(spl[1]);
		int B = Integer.parseInt(spl[2]);
		int N = Integer.parseInt(spl[3]);
		sc.close();
		
		int cnt = 0;
		for(int r = 0;r <= N;r++){
			for(int g = 0;g <= N;g++){
				int num = N - r * R - g * G;
				if(num / B >= 0 && num % B == 0){
					cnt++;
				}
			}
		}
		System.out.println(cnt);
	}
}

Measured memory_bytes: 23892
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		int takaHP = sc.nextInt();
        int takaA = sc.nextInt();
		int aokiHP = sc.nextInt();
        int aokiA = sc.nextInt();
      
      while(takaHP>0){
        aokiHP -= takaA;
        if(aokiHP<=0){
          break;
        }
        takaHP -= aokiA;
      }
      
      if(aokiHP<=0){
      System.out.println("Yes");
      }else{
      System.out.println("No");
      }
    }
}


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

#define len(x)  (int((x).size()))
#define append push_back
#define pp make_pair
#define ff(a, b)    for (int a = 0; a < int(b); ++a)
#define kk(n)    ff(k, n)
#define xx(n)    ff(x, n)
#define yy(n)    ff(y, n)
#define ii(n)    ff(i, n)
#define fff(a, b, c) for (int a = int(b); a < int(c); ++a)
#define kkk(a, b) fff(k, a, b)
#define xxx(a, b) fff(x, a, b)
#define yyy(a, b) fff(y, a, b)
#define iii(a, b) fff(i, a, b)
#define bb begin()
#define ee end()
#define uu first
#define vv second
#define all(x)  (x).bb, (x).ee
#define ite(v)   decltype((v).bb)
#define fe(i, v) for(ite(v) i = (v).bb; i != (v).ee; ++i)
#define err(...)    { fprintf(stderr, __VA_ARGS__); fflush(stderr); }
#define zz(array, byte)   memset(array, byte, sizeof(array));

using LL = long long;
using DD = long double;
using pii = pair<int, int>;


const LL  INFLL  = 0x7f7f7f7f7f7f7f7fLL;
const int INFint = 0x7f7f7f7f;  //Works with memset(..).
   




int main() {
    ios_base::sync_with_stdio(false);     cin.tie(NULL);
    //cout << '\n';     //Avoid flushing with endl.
    cout.precision(16);


    int N, M;
    cin >> N >> M;
    vector<int> seen(N, 0);
    ii (M) {
        int a, b;
        cin >> a >> b;
        --a, --b;
        seen[a]++;
        seen[b]++;
    }

    ii (N) {
        if ((seen[i] & 1)) {
            cout << "NO\n";
            return 0;
        }
    }

    cout << "YES\n";

    

    return 0;
}



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

signed main(){
	lint N, sum = 0; cin >> N;
	vector<lint> a(N);
	for(lint i = 0; i < N; i++) {cin >> a[i]; sum += abs(a[i]);};
	sort(a.begin(), a.end());
	if(a[0] > 0) sum -= a[0] * 2;
	if(a.back() < 0) sum += a.back() * 2;
	lint x = a[0];
	cout << sum << endl;
	for(lint i = 1; i < N - 1; i++){
		if(a[i] >= 0){
			cout << x << " " << a[i] << endl;
			x -= a[i];
		}
	}
	cout << a.back() << " " << x << endl;
	x = a.back() - x;
	for(lint i = 1; i < N - 1; i++){
		if(a[i] < 0){
			cout << x << " " << a[i] << endl;
			x -= a[i];
		}
	}
}

Measured memory_bytes: 2688
#include <bits/stdc++.h>
#define mem(a,b) memset(a,b,sizeof a)
using namespace std;
typedef long long ll;
int main()
{
    char a;
    cin>>a;
    if(a>='a'&&a<='z')
        cout<<'a';
    else if(a>='A'&&a<='Z')
        cout<<'A';
    return 0;
}

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

int main() {
	int N;
    cin >> N;
  vector<int> vec(N);
  
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }
  
  sort(vec.begin(), vec.end());
  reverse(vec.begin(), vec.end());
  
  int sum = 0;
  
  for (int i = 0; i < N; i++) {
    sum += (i & 1) ? -vec[i] : vec[i];
  }
  
  cout << sum << endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

import sys

debug = False

def log(text):
    if debug:
        print(text)

def parse_input(lines_as_string = None):

    global debug
    lines = []
    if lines_as_string is None:
        debug = False
        lines.append(input())
        n = int(lines[0])
        for i in range(n):
            lines.append(input())
    else:
        debug = True
        lines = [e for e in lines_as_string.split("\n")][1:-1]
        n = int(lines[0])

    s = lines[1:]

    return (n, s)


def cnt_dict_to_tuple(cnt_dict):
    t = (
        cnt_dict.get("a", 0),
        cnt_dict.get("b", 0),
        cnt_dict.get("c", 0),
        cnt_dict.get("d", 0),
        cnt_dict.get("e", 0),
        cnt_dict.get("f", 0),
        cnt_dict.get("g", 0),
        cnt_dict.get("h", 0),
        cnt_dict.get("i", 0),
        cnt_dict.get("j", 0),
        cnt_dict.get("k", 0),
        cnt_dict.get("l", 0),
        cnt_dict.get("m", 0),
        cnt_dict.get("n", 0),
        cnt_dict.get("o", 0),
        cnt_dict.get("p", 0),
        cnt_dict.get("q", 0),
        cnt_dict.get("r", 0),
        cnt_dict.get("s", 0),
        cnt_dict.get("t", 0),
        cnt_dict.get("u", 0),
        cnt_dict.get("v", 0),
        cnt_dict.get("w", 0),
        cnt_dict.get("x", 0),
        cnt_dict.get("y", 0),
        cnt_dict.get("z", 0),
    )
    return t



def solve(n, s):

    cnt_tuple_dict = dict()
    for i in range(n):
        cnt_dict = dict()    
        for c in s[i]:
            cnt = cnt_dict.get(c, 0)
            cnt = cnt + 1
            cnt_dict[c] = cnt
    
        t = cnt_dict_to_tuple(cnt_dict)
        if debug:
            log("t=%s" % str(t))

        same_cnt_index_list = cnt_tuple_dict.get(t, [])
        same_cnt_index_list.append(i)
        cnt_tuple_dict[t] = same_cnt_index_list


    result = 0
    for t, same_cnt_index_list in cnt_tuple_dict.items():
        n = len(same_cnt_index_list)

        result = result + int(n*(n-1)/2)

    return result


def main():
    # 出力

    print("%s" % solve(*parse_input()))

if __name__ == '__main__':

    main()
	

Measured memory_bytes: 57112
n = gets.to_i
a = gets.split.map &:to_i
puts a * " "

1.upto(n-1){|i|
  v = a[i]
  j = i - 1
  while j >= 0 && a[j] > v
    a[j + 1] = a[j]
    j -= 1
  end
  a[j+1] = v
  puts a * " "
}



Measured memory_bytes: 6880
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <numeric>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

#define rep(i, N) for(int i = 0; i < N; ++i)

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))


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

    int h1, m1, h2, m2, k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;

    cout << (h2 * 60 + m2 - h1 * 60 - m1) - k << "\n";

    return 0;
}



Measured memory_bytes: 3592
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <queue>

#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,x,n) for(int i=x; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define all(X) (X).begin(),(X).end()
#define X first
#define Y second
#define pb push_back
#define eb emplace_back

using namespace std;
typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

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 (a>b) { a=b; return 1; } return 0; }

template<class A, size_t N, class T> void Fill(A (&a)[N], const T &v){ fill( (T*)a, (T*)(a+N), v ); }

const ll INF = 0x3fffffff;


int vc[100005] = {};
int vd[100005] = {};
vector<int> edge[100005];

void bfs(int v, int d, int c, vector<bool> &visited){
	//cout << "bfs: " << v << " " << d << " " << c << endl;
	queue<pii> que;
	que.emplace(v, d);
	while( !que.empty() ){
		v = que.front().X;
		d = que.front().Y;
		que.pop();
		if( visited[v] ) continue;
		visited[v] = true;
		if( vc[v] == 0 ) vc[v] = c;
		if( !chmax( vd[v], d ) ) continue;
		for(auto t: edge[v]) if( !visited[t] ){
			que.emplace( t, d-1 );
		}
	}
}

int main(){
	ios_base::sync_with_stdio(0);
	int N, M, Q;
	int v[100005], d[100005], c[100005];

	cin >> N >> M;
	rep(i,M){
		int a, b;
		cin >> a >> b;
		a--; b--;
		edge[a].push_back(b);
		edge[b].push_back(a);
	}
	cin >> Q;
	rep(i,Q){
		cin >> v[i] >> d[i] >> c[i];
		v[i]--;
	}

	rrep(i,Q){
		vector<bool> visited(100005, false);
		bfs(v[i], d[i], c[i], visited);
	}

	rep(i,N){
		cout << vc[i] << endl;
	}

	return 0;
}


Measured memory_bytes: 8960
#include <iostream>
#include <algorithm>

using namespace std;


int main()
{
    int n;
    int data[105];

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

    sort(data, data + n);

    int ans = 1;
    for (int i = 0; i < n - 1; i++) {
        if ( data[i] <  data[i + 1] ) {
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n); for (int i=0; i<(n); i++)//第一引数の変数をカウンタ変数としてn回回す
using veci = vector<int>;
using vecl = vector<long long>;
using vecd = vector<double>;
using vecs = vector<string>;
int a[2][55];
int b[55];
int main(){//最後の数字を読み取り、それで分岐する
  int n;
  cin >> n;
  int cn = n % 10;
  if (cn == 2 ||cn == 4 ||cn == 5 ||cn == 7 ||cn == 9){
    cout << "hon" << endl;
    return 0;
  }
  else if(cn == 0 ||cn == 1 ||cn == 6 ||cn == 8){
    cout << "pon" << endl;
    return 0;
  }
  else if(cn == 3){
    cout << "bon" << endl;
  }
}

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

int main()
{
    int n,m; cin >> n >> m;
    int sum = 0;
    int ar[n];
    for(int i=0; i<n; i++){
        cin >> ar[i]; sum += ar[i];
    }
    int m_ = sum/(4*m); //quotient between integers are rounded down in C++ or Java! :(
    if(sum%(4*m)!=0) m_++;
    for(int i=0; i<n; i++){
        if(ar[i]>=m_) m--;
        if(m==0) break;
    }
    if(m==0) cout << "Yes";
    else cout << "No";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1001001001;
const int mINF = -1001001001;


int main() {
int n,d;
cin >> n >> d;
int x[n][d];
REP(i,n) {
  REP(j,d) {
    cin >> x[i][j];
  }
}
int ans=0;
int sum;
REP(i,n-1) {
  for(int j=i+1;j<n;j++) {
    sum =0;
    for(int k=0;k<d;k++) {
      sum+=(x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
    }
    for(int l=0;l<130;l++) {
      if(sum==l*l) ans++;
    }
  }
}
cout << ans << endl;
return 0;
}


Measured memory_bytes: 256
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    let l: usize = iter.next().unwrap().parse().unwrap();
    let r: usize = iter.next().unwrap().parse().unwrap();

    let mut ans = std::usize::MAX;
    for i in l..r + 1 {
        for j in i + 1..r + 1 {
            ans = std::cmp::min(ans, i % 2019 * j % 2019);
            if ans == 0 {
                break;
            }
        }
        if ans == 0 {
            break;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <iostream>
using namespace std;
int main()
{
  string S;
  cin >> S;
  bool black = false;
  if (S[0] == 'B')
    black = true;
  int ans = 0;
  for (int i = 1; i < S.length(); i++)
  {
    if (black && S[i] == 'W')
    {
      ans++;
      black = false;
    }
    else if (!black && S[i] == 'B')
    {
      ans++;
      black = true;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 512
#include "bits/stdc++.h"
using namespace std;
bool CanGo(vector<vector<char>>& Maze, int R, int C, int x, int y) {
	if (x < 0 || x >= R || y < 0 || y >= C || Maze.at(x).at(y) == '#') return false;
	else return true;
}
void BFS(vector<vector<char>>& Maze, int R, int C, pair<int, int>Start, vector<vector<int>>&Count, vector<vector<bool>>&reach) {
	queue<pair<int, int>>Q;
	reach.at(Start.first).at(Start.second) = true;
	Q.push(Start);
	reach.at(Start.first).at(Start.second) = true;
	Count.at(Start.first).at(Start.second) = 0;
	while (!Q.empty()) {
		pair<int, int>V = Q.front(); Q.pop();
		bool check = false;
		if (CanGo(Maze, R, C, V.first, V.second + 1)) {
			check = true;
			if (!reach.at(V.first).at(V.second + 1)) {
				reach.at(V.first).at(V.second + 1) = true;
				Count.at(V.first).at(V.second + 1) = Count.at(V.first).at(V.second) + 1;
				Q.push(make_pair(V.first, V.second + 1));
			}
		}
		if (CanGo(Maze, R, C, V.first, V.second - 1)) {
			check = true;
			if (!reach.at(V.first).at(V.second - 1)) {
				reach.at(V.first).at(V.second - 1) = true;
				Count.at(V.first).at(V.second - 1) = Count.at(V.first).at(V.second) + 1;
				Q.push(make_pair(V.first, V.second - 1));
			}
		}
		if (CanGo(Maze, R, C, V.first + 1, V.second)) {
			check = true;
			if (!reach.at(V.first + 1).at(V.second)) {
				reach.at(V.first + 1).at(V.second) = true;
				Count.at(V.first + 1).at(V.second) = Count.at(V.first).at(V.second) + 1;
				Q.push(make_pair(V.first + 1, V.second));
			}
		}
		if (CanGo(Maze, R, C, V.first - 1, V.second)) {
			check = true;
			if (!reach.at(V.first - 1).at(V.second)) {
				reach.at(V.first - 1).at(V.second) = true;
				Count.at(V.first - 1).at(V.second) = Count.at(V.first).at(V.second) + 1;
				Q.push(make_pair(V.first - 1, V.second));
			}
		}
	}
}
int main() {
	int H, W;
	cin >> H >> W;
	vector<vector<char>>Maze(H, vector<char>(W));
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			cin >> Maze.at(i).at(j);
		}
	}
	int ans = -1;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (Maze.at(i).at(j) == '#') continue;
			vector<vector<int>>Count(H, vector<int>(W, -1));
			vector<vector<bool>>reach(H, vector<bool>(W, false));
			BFS(Maze, H, W, make_pair(i, j), Count, reach);
			int sum = -1;
			for (int k = 0; k < H; k++) {
				for (int l = 0; l < W; l++) {
					sum = max(sum, Count.at(k).at(l));
				}
			}
			ans = max(ans, sum);
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
from numba import njit
 
@njit(cache=True)
def convolve(a, b):
    def poww(aa, bb, mm):
        ss = 1
        tt = aa
        while bb:
            if bb % 2:
                ss = ss * tt % mm
                bb -= 1
            tt = tt * tt % mm
            bb //= 2
        return ss
    def fft(n, p, g, w, invw, f):
        d = n // 2
        v = w
        while d >= 1:
            u = 1
            for i in range(d):
                for j in range(i, n, 2*d):
                    f[j], f[j+d] = (f[j] + f[j+d]) % p, u * (f[j] - f[j+d]) % p
                u = u * v % p
            v = v * v % p
            d //= 2
 
    def ifft(n, p, g, w, invw, f):
        d = 1
        while d < n:
            v = poww(invw, n // (2 * d), p)
            u = 1
            for i in range(d):
                for j in range(i, n, 2*d):
                    f[j+d] *= u
                    f[j], f[j+d] = (f[j] + f[j+d]) % p, (f[j] - f[j+d]) % p
                u = u * v % p
            d *= 2
 
    p = 1107296257
    g = 5
    n0, n1 = len(a), len(b)
    n = 1
    while n < max(n0, n1) * 2:
        n *= 2
    a = a + [0] * (n-n0)
    b = b + [0] * (n-n1)

    w = poww(g, (p - 1) // n, p)
    invw = poww(w, p-2, p)
    fft(n, p, g, w, invw, a), fft(n, p, g, w, invw, b)
    for i in range(n):
        a[i] = a[i] * b[i] % p
    ifft(n, p, g, w, invw, a)
    invn = poww(n, p - 2, p)
    for i in range(n0 + n1 - 1):
        a[i] = a[i] * invn % p
    return a[:n0 + n1 - 1]

N = 100000
A = []
B = []
s = 0
for i in range(N):
    s = (s * 3 + i * 7) % 100
    a = s
    b = (s * 3 + a * 11) % 100
    A.append(a)
    B.append(b)

AB = convolve(A, B)


#####
A, B, C, K = map(int, input().split())
if K <= A + B:
    print(min(A, K))
else:
    print(A - (K - A - B))

Measured memory_bytes: 117828
n, m = map(int, input().split())

h = list(map(int, input().split()))

flags = [True] * n

for _ in range(m):
    a, b = map(int, input().split())
    if h[a-1] > h[b-1]:
        flags[b-1] = False
    elif h[b-1] > h[a-1]:
        flags[a-1] = False
    else:
        flags[a-1] = False
        flags[b-1] = False

print(flags.count(True))


Measured memory_bytes: 84780
#include<cstdio>
#include<iostream>
#include<sstream>
#include<cmath>
#include<algorithm>
#include<map>
#include<set>
#include<list>
#include<vector>
#include<stack>
#include<queue>
#include<string>
#include<iomanip>
#include<fstream>
#include<ctime>
using namespace std;
typedef vector<int> VI;
typedef pair <int,int> ii;
typedef long long LL;
#define pb push_back
const int INF = 2147483647;

LL k;
int c, i, maxx, tab[20];

int get() {
	int res = 0;
	for (int i=0;i<c;i++) {
		res += tab[i];
	}
	return res;
}

int main() {
scanf("%lld", &k);
c = 0;
while (k > 0) {
	tab[c] = k % 10;
	k /= 10;
	c++;
}
maxx = get();
for (i=1;i<c;i++) {
	tab[i - 1] = 9;
	if (tab[i] > 0) {
		tab[i]--;
		maxx = max(maxx, get());
	}
}
printf("%d\n", maxx);
return 0;
}



Measured memory_bytes: 256
/*  -*- coding: utf-8 -*-
 *
 * b.cc: B: Collatz Problem
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_M = 1000000;

/* typedef */

/* global variables */

bool used[MAX_M + 1];

/* subroutines */

/* main */

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

  int m = 1, a = s;
  while (! used[a]) {
    used[a] = true;
    m++;
    a = (a & 1) ? 3 * a + 1 : a / 2;
  }

  printf("%d\n", m);
  return 0;
}


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

int main(void){
    int n;
    cin >> n;
    int64_t sum = 0;
    for(int i=1; i<=n; i++){
        for(int j=i; j<=n; j+=i){
            sum += j;
        }
    }
    cout << sum << '\n';
    return 0;
}

Measured memory_bytes: 3560
#include <bits/stdc++.h>
#define f(I, a, b) for (int I = a; I <= b; I++) 
using namespace std;

int main() {
	int N, W;
    cin >> N >> W;
  	int w[N], v[N];
  	f(i, 0, N-1) cin >> w[i] >> v[i];
  	long long dp[N+1][W+1] = {};
  	f(i, 0, N-1){
      f(j, 0, W){
        if (j - w[i] >= 0){
          dp[i+1][j] = max(dp[i][j], dp[i][j-w[i]]+v[i]);
        } else {
          dp[i+1][j] = dp[i][j];
        }
      }
    }
  	long long int ans = 0;
  	f(i, 0, W){
      ans = max(ans, dp[N][i]);
    }
  	cout << ans << endl;
}

Measured memory_bytes: 79104
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
const int INF = 100000000;

ll i,j,k;
vector<long long> ret;
vector<long long> divisor(long long n) {
    
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    sort(ret.begin(), ret.end()); // 昇順に並べる
    return ret;
}

int main(){
    ll n,m,ans=-1;cin>>n>>m;//n:数列の大きさ　m:数列の和の値
    
    divisor(m);

    for(i=0;i<ret.size();i++){
        if(ret[i]<=m/n){ans=max(ans,ret[i]);}
    }
    cout<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 256
h,w,k = map(int, input().split())
ss = [input() for _ in range(h)]

ans = 0
for r in range(1<<h):
    for c in range(1<<w):
        cnt = 0
        for i in range(h):
            for j in range(w):
                if r >> i & 1 and c >> j & 1 and ss[i][j] == '#':
                    cnt += 1
        if cnt == k:
            ans += 1
print(ans)

Measured memory_bytes: 9188
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <queue>
using namespace std;
#define FOR(i,a,b) for(int (i)=(a);(i)<=(b);(i)++)
#define rep(i,n) FOR(i,0,n-1)
#define int long long
#define MOD 998244353
#define MAXN  100005
#define P pair<int,int>


signed main(){
	
	string s,t;cin>>s>>t;
	
	for(int i = s.size()-t.size();i>=0;i--)
	{
		bool ok = true;
		rep(j,t.size())
		{
			if(s[i+j]=='?')continue;
			if(s[i+j] != t[j]) ok =false;
		}
		
		if(ok)
		{
			rep(j,i) cout << (s[j] == '?'?'a':s[j]);
			cout << t;
			for(int j=i+t.size();j<s.size();j++)cout << (s[j] == '?'?'a':s[j]);
			return 0;
		}
	}
	cout << "UNRESTORABLE"<<endl;
	
	
}
 

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <memory.h>
#include <map>

using namespace std;
typedef long long LL;
const int maxn = 20005;
const int mod = 1e9+7;

map<LL,int> h;LL x[maxn],ans;
int n,a[maxn][4],cnt[maxn],v[maxn],tot,p[maxn];
LL cal[maxn][5],pw[maxn][5];
bool cmp(int p,int q) {
	for (int i=0;i<4;i++)
		if (x[p+i]!=x[q+i]) return x[p+i]<x[q+i];
	return 0;
}
int getId(int a,int b,int c,int d,bool ins=false)
{
	x[0]=x[4]=a;x[1]=x[5]=b;x[2]=x[6]=c;x[3]=x[7]=d;int p=0;
	for (int i=1;i<4;i++) if (cmp(i,p)) p=i;
	LL num=(x[p]<<30)|(x[p+1]<<20)|(x[p+2]<<10)|x[p+3];
	ins&&!h[num]?h[num]=++tot:0;return h[num];
}
int getv(int a,int b,int c,int d)
{
	return (a!=c||b!=d)?1:(a!=b?2:4);
}
void calc(int a,int b,int c,int d,int e,int f,int g,int h)
{
	/*
      e-----h               
	 /|    /|            
	a-----b |           
	| |   | |           
	| f---|-g           
	|/    |/
	d-----c         
	*/
	p[1]=getId(e,h,b,a);
	p[2]=getId(h,g,c,b);
	p[3]=getId(g,f,d,c);
	p[4]=getId(f,e,a,d);
	sort(p+1,p+5);LL res=1ll;
	for (int i=1;i<=4;) {
		int j=i;while (j<=4&&p[j]==p[i]) ++j;
		if (cnt[p[i]]<j-i) return ;
		res*=pw[v[p[i]]][j-i]*cal[cnt[p[i]]][j-i];i=j;
	}
	ans+=res;
}
int main()
{
	#ifdef Amberframe
		freopen("arc062e.in","r",stdin);
		freopen("arc062e.out","w",stdout);
	#endif
	scanf("%d",&n);
	for (int i=1;i<=n;i++) {
		scanf("%d %d %d %d",&a[i][0],&a[i][1],&a[i][2],&a[i][3]);
		int id=getId(a[i][0],a[i][1],a[i][2],a[i][3],1);cnt[id]++;
		v[id]=getv(a[i][0],a[i][1],a[i][2],a[i][3]);
	}
	for (int i=1;i<=4;i++) {
		pw[i][0]=1ll;
		for (int j=1;j<=4;j++)
			pw[i][j]=pw[i][j-1]*i;
	}
	for (int i=1;i<=n;i++) {
		cal[i][0]=1ll;
		for (int j=1;j<=4;j++)
			cal[i][j]=cal[i][j-1]*(i-j+1);
	}
	for (int i=1;i<=n;i++)
	for (int j=i+1;j<=n;j++) {
		int id1=getId(a[i][0],a[i][1],a[i][2],a[i][3]);
		int id2=getId(a[j][0],a[j][1],a[j][2],a[j][3]);
		cnt[id1]--;cnt[id2]--;
		calc(a[i][0],a[i][1],a[i][2],a[i][3],a[j][0],a[j][1],a[j][2],a[j][3]);
		calc(a[i][0],a[i][1],a[i][2],a[i][3],a[j][1],a[j][2],a[j][3],a[j][0]);
		calc(a[i][0],a[i][1],a[i][2],a[i][3],a[j][2],a[j][3],a[j][0],a[j][1]);
		calc(a[i][0],a[i][1],a[i][2],a[i][3],a[j][3],a[j][0],a[j][1],a[j][2]);
		cnt[id1]++;cnt[id2]++;
	}
	printf("%lld",ans/3);
	return 0;
}

Measured memory_bytes: 80128
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        
        UnionFind uf = new UnionFind(n);
        for (int i = 0; i < m; i++) {
            int x = sc.nextInt()-1;
            int y = sc.nextInt()-1;
            uf.unite(x, y);
        }
        
        int max = 0;
        for (int i = 0; i < n; i++) {
            max = Math.max(max, uf.size[uf.root(i)]);
        }
        System.out.println(max);
    }
}

class UnionFind {
    int[] par;  // 自身の親
    int[] size; // ※(自身の属するグループの要素数はsize[uf.root(i)]。)
                // (※[i]全てに対して↑を更新するのは時間がかかるので)
    int connectedComponent;

    UnionFind(int n) {
        par = new int[n];
        for (int i = 0; i < n; i++) {
            par[i] = i;
        }
        
        size = new int[n];
        Arrays.fill(size, 1);
        connectedComponent = n;
    }

    int root(int x) {
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
        // 1-2-4の場合、4の親=2を4の根=1に繋ぎ変えた上で親を返す
        // ↑根まで辿る深さ(計算量)を減らす為
        // return a = b;とは、aにbを代入し、aを返すという意味
    }
    
    // 点x, yを連結させる=同じグループにする
    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx != ry) {
            par[ry] = rx;
            
            int resize = size[rx] + size[ry];
            size[rx] = resize;
            size[ry] = resize;
            connectedComponent--;
        }
    }
    
    // 同グループか否か
    boolean same(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
}

Measured memory_bytes: 61452
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  int a,min1;
  cin >>n;
  min1 = 100;
  for(int i=0;i<n;i++){
    cin >> a;
    int count = 0;
    while (a%2==0){
        a /= 2.0;
        count += 1;
    }
    min1 = min(min1,count);
  }
  cout << min1 << endl;
}

Measured memory_bytes: 256
L, R = map(int, input().split())
if R-L >=2019:
    minimum = 0
else:
    left, right = L%2019, R%2019
    minimum = 2018**2
    for i in range(left, right + 1):
        for j in range(i+1, right+1):
            minimum = min(minimum, i*j%2019)
print(minimum)



Measured memory_bytes: 9064
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;



int main(){
    ll A;
    cin >> A;
    ll B;
    cin >> B;
    ll K;
    cin >> K;
    cout<<max(0LL,A-K)<<" ";
    if(K>A+B)cout<<0<<endl;
    else cout<<min(A+B-K,B);

return 0;


}  



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;


int main()
{
    ll n;
    cin >> n;
    ll total = 0;
    REP(i, n) {
        ll l, r;
        cin >> l >> r;
        total += r - l + 1;
    }
    cout << total << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>



#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = (int)(n-1); i >= 0; i--)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

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

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;cin>>n;
  rep(i,n+1){
    if(((ll)(i*1.08))==n){
      cout<<i<<endl;
      return 0;
    }
  }
  cout<<":("<<endl;
  return 0;

}


Measured memory_bytes: 764
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<queue>
#include<deque>
#include<map>
using namespace std;
using ll = long long;

int main() {
    int n; cin >> n;
    string s, t; cin >> s >> t;
    string ans = "";
    for (int i = 0; i < n; i++)
    {
        ans += s[i];
        ans += t[i];
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
def check_dup(word_list, word):
  return word not in word_list

def check_chain(word_list, current_str):
  if len(word_list) == 0:
    return True
  return word_list[-1][-1] == current_str[0]

def main():
  input_num = int(input())
  input_str = [input().rstrip() for i in range(input_num)]
  result = 'Yes'
  word_list = []
  for word in input_str:
    if not check_dup(word_list, word) or not check_chain(word_list, word):
      result = 'No'
      break
    word_list.append(word)
  print(result)
if __name__ == '__main__':
  main()

Measured memory_bytes: 3060
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int main()
{
	int n,res=0;
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	{
		int l,r;
		scanf("%d%d",&l,&r);
		res+=(r-l+1);
	}
	printf("%d\n",res);
}


Measured memory_bytes: 256
s = str(input())
year = ""
for i in range(0,4):
    year += s[i]
year = int(year)
if(s[5] == 0):
    mon = int(s[6])
else:
    mon = int(s[5] + s[6])
if(year >= 2019):
    if(year >= 2020):
        print("TBD")
    elif(mon >= 5):
        print("TBD")
    else:
        print("Heisei")
else:
    print("Heisei")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define int long long
//#define M 1000000007
#define M 998244353
const int inf=4e18;
int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	int x,y,a,b,c;cin>>x>>y>>a>>b>>c;
	int red[a],green[b],i;
	vector<int> v;
	for(i=0;i<a;i++)
		cin>>red[i];
	for(i=0;i<b;i++)
		cin>>green[i];
	for(i=0;i<c;i++)
	{
		int x;cin>>x;
		v.emplace_back(x);
	}
	sort(red,red+a,greater<int> ());
	sort(green,green+b,greater<int> ());
	for(i=0;i<x;i++)
		v.emplace_back(red[i]);
	for(i=0;i<y;i++)
		v.emplace_back(green[i]);
	sort(v.begin(),v.end(),greater<int> ());
	int o=0;
	for(i=0;i<x+y;i++)
		o+=v[i];
	cout<<o<<endl;
}

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

ll n, m, x[100008], mod[100008], p[100008];
string s;

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	cin >> n >> m;
	rep(i, 0, n-1){
		cin >> x[i];
	}
	sort(x, x+n);
	
	memset(mod, 0, sizeof(mod));
	memset(p, 0, sizeof(p));
	ll buf = -1;
	rep(i, 0, n-1){
		mod[x[i]%m]++;
		if(x[i] == buf){
			p[x[i]%m]++;
			buf = -1;
		}
		else{
			buf = x[i];
		}
	}
	
	ll ans = 0;
	ans += mod[0]/2;
	rep(i, 1, ((m-1)/2)){
		if(mod[i] < mod[m-i]){
			ans += mod[i];
			ans += min(p[m-i], (mod[m-i]-mod[i])/2);
		}
		else{
			ans += mod[m-i];
			ans += min(p[i], (mod[i]-mod[m-i])/2);
		}
	}
	if(m%2 == 0){
		ans += mod[m/2]/2;
	}
	
	print(ans)
	return 0;
}

Measured memory_bytes: 2560
package main

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

type TupleInt struct {
	first  int
	second int
}

func main() {
	sc := NewScanner()
	N, M := sc.NextInt(), sc.NextInt()
	A := make(SortInterFace, N)
	for i := 0; i < N; i++ {
		A[i] = TupleInt{sc.NextInt(), sc.NextInt()}
	}
	k := 0
	sum := 0
	sort.Sort(A)
	for i := 0; i < N; i++ {
		l := max(0, min(M-k, A[i].second))
		sum += A[i].first * l
		k += l
	}
	fmt.Println(sum)

}
func min(a int, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a int, b int) int {
	if a < b {
		return b
	}
	return a
}

type SortInterFace []TupleInt

func (s SortInterFace) Len() int {
	return len(s)
}
func (s SortInterFace) Less(i, j int) bool {
	return s[i].first < s[j].first
}
func (s SortInterFace) Swap(i, j int) {
	s[i], s[j] = s[j], s[i]
}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextFloat() float64 {
	v, _ := strconv.ParseFloat(s.Next(), 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


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

int main() {
	char a[10];
	scanf("%s", a);

	if (strcmp(a, "Sunny")==0) {
		printf("Cloudy");
	}
	else if (strcmp(a, "Cloudy")==0) {
		printf("Rainy");
	}
	else {
		printf("Sunny");
	}

	return 0;
}

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

int main()
{
    int N; cin>>N;
    vector<string> vs(N);
    for(int i=0;i<N;i++){
        string s; cin>>s;
        sort(s.begin(),s.end());
        vs[i]=s;
    }
    sort(vs.begin(),vs.end());

    ll ans=0,cnt=1;
    for(int i=1;i<N;i++){
        if(vs[i-1]==vs[i]){
            cnt++;
        }else{
            ans+=cnt*(cnt-1)/2;
            cnt=1;
        }
    }
    ans+=cnt*(cnt-1)/2;
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 5760
#define onlycc ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#define MOD 1000000007
using namespace std;

typedef long long ll;

ll a[200000], n, e, square;

ll mod(ll a, int b)
{
    if(b == 1) return a;
    if(b == 0) return 1;

    ll tmp = mod(a, b/2);
    if(b%2 == 1) return (((tmp*tmp)%MOD)*a)%MOD;
    else return (tmp*tmp)%MOD;
}

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

    if(n == 1)
    {
        cout << a[0]%MOD;
        return 0;
    }

    for(int i = 0; i < n; i++)
        e = (e%MOD+a[i]%MOD)%MOD;

    e = (e%MOD*e%MOD)%MOD;

    for(int i = 0; i < n; i++)
        square = ((square%MOD)+((a[i]%MOD*a[i]%MOD)%MOD)) % MOD;

    cout << ((e%MOD-square%MOD+MOD)%MOD)*mod(2, MOD-2)%MOD;

    return 0;
}


Measured memory_bytes: 5180
import java.util.Scanner;

public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
        int K=sc.nextInt();
        String S=sc.next();
    int X=S.length();
    if(X<=K) {
    	System.out.println(S);
    }else {
    	String Z=S.substring(0,K);
    	System.out.println(Z+"...");
    }
    	
    }
}

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

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
	ll x; // typedef long long ll;
	mint(ll x = 0) :x((x%mod + mod) % mod) {}
	mint operator-() const { return mint(-x); }
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
	mint operator+(const mint a) const { return mint(*this) += a; }
	mint operator-(const mint a) const { return mint(*this) -= a; }
	mint operator*(const mint a) const { return mint(*this) *= a; }
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime mod
	mint inv() const { return pow(mod - 2); }
	mint& operator/=(const mint a) { return *this *= a.inv(); }
	mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }

int main() {
	string L;
	cin >> L;
	mint ans = 0;
	mint l = 1;
	mint three = 3;
	mint r = three.pow((long long)L.size()-1);
	for (int n = 0;n<L.size();++n) {
		if ('1' == L[n] || n == L.size()-1) {
			ans += l * r;
		}
		r /= three;
		if ('1'  == L[n]) {
			l *= 2;
		}
	}
	if ('1' == L[L.size() - 1]) {
		ans += l;
	}
	cout  << ans <<endl;
	return 0;
}

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

using namespace std;

int a[25][25];
long long score[(1 << 16) + 5], dp[(1 << 16) + 5];

long long solve(int mask) {
	if (mask == 0) return 0LL;
	if (dp[mask] != -1) return dp[mask];
	for (int i = mask; ; i = (i - 1) & mask) {
		if (i == 0) break;
		dp[mask] = max(dp[mask], solve(mask ^ i) + score[i]);
	}
	
	return dp[mask];
}

int main() {
	int n;
	scanf("%d", &n);
	
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) scanf("%d", &a[i][j]);
	}
	
	for (int i = 0; i < (1 << n); i++) {
		for (int j = 0; j < n; j++) {
			if ((i & (1 << j)) == 0) continue;
			for (int k = j + 1; k < n; k++) {
				if ((i & (1 << k)) == 0) continue;
				score[i] += a[j][k];
			}
		}
	}
	
	memset(dp, -1, sizeof(dp));
	
	printf("%lld\n", solve((1 << n) - 1));
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
//using namespace __gnu_pbds;
#define rep(i,a,b) for(i=(a);i<=(b);i++)
#define ll long long
#define pll pair<ll, ll>
#define pii pair<int,int>
#define pb push_back
#define F first
#define S second
#define mod 1000000007
#define maxn 100005
#define inf 1e18
#define boost ios::sync_with_stdio(false);cin.tie(0)
#define fr freopen("source.txt","r",stdin),freopen("output.txt","w",stdout)
#define SET(a,b) memset(a,b,sizeof(a))
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define all(x) x.begin(), x.end()
#define ps(x,y) fixed<<setprecision(y)<<x
//template<typename T>
//using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
template<class A, class B> ostream& operator << (ostream& out, const pair<A, B> &a) {
	return out <<  "(" << a.F << ", " << a.S << ")";
}
 
template<class A> ostream& operator << (ostream& out, const vector<A> &a) {
	out << "[";
	for (auto it = a.begin(); it != a.end(); ++it) {
		if (it != a.begin())
			out << ", ";
		out << *it;
	}
	return out << "]";
}
int main()
{
    boost;
    ll n,i,j,x,t,y,m;
    cin>>n;
    ll a[n];
    map<ll,ll>mp;
    for(i=0;i<n;i++) {
        cin>>a[i];
        mp[a[i]]++;
    }
    ll ans=0;
    for(auto p:mp){
        x=p.S;
        ans+=((x*(x-1))/2);
    }
    for(i=0;i<n;i++){
        x=mp[a[i]];
        y=ans;
        y-=((x*(x-1))/2);
        x--;
        y+=((x*(x-1))/2);
        cout<<y<<"\n";
    }
}

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

int main() {
    int H, W; cin >> H >> W;
    vector<string> S(H);
    for (int i = 0; i < H; i++) cin >> S[i];

    vector<vector<int>> nw(H, vector<int>(W));
    vector<vector<int>> nh(H, vector<int>(W));

    for (int i = 0; i < H; i++) {
        int w = 0;
        int l = 0;

        for (int j = 0; j < W; j++) {
            if (S[i][j] == '.') {
                w++;
            } else {
                for (int k = l; k < j; k++) {
                    nw[i][k] = w;
                }
                nw[i][j] = 0;
                w = 0;
                l = j + 1;
            }
        }

        for (int j = l; j < W; j++) nw[i][j] = w;
    }

    for (int j = 0; j < W; j++) {
        int h = 0;
        int u = 0;

        for (int i = 0; i < H; i++) {
            if (S[i][j] == '.') {
                h++;
            } else {
                for (int k = u; k < i; k++) {
                    nh[k][j] = h;
                }
                nh[i][j] = 0;
                h = 0;
                u = i + 1;
            }
        }

        for (int i = u; i < H; i++) nh[i][j] = h;
    }

    int out = 0;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            out = max(out, nh[i][j] + nw[i][j] - 1);
        }
    }

    cout << out << endl;

    return 0;
}


Measured memory_bytes: 35712
#include<stdio.h>
int main()
{
  long long int a, b, c, i, ans=1;
  scanf("%lld %lld", &a, &b);
  for(i=1; i<=a; i++) ans*=100;
  c=b/100;
  ans*=(b+c);
  printf("%lld", ans);
  return 0;
}

Measured memory_bytes: 128
n = int(input())
s = input()

change = []
s0 = 0
for i in range(1, n):
    if s[i] == "E":
        s0 = s0 + 1
change.append(s0)

for i in range(1, n - 1):
    if s[i - 1] == "W":
        s0 = s0 + 1
    if s[i] == "E":
        s0 = s0 - 1
    change.append(s0)

s0 = 0
for i in range(n - 1):
    if s[i] == "W":
        s0 = s0 + 1
change.append(s0)

print(min(change))

Measured memory_bytes: 15520
class Decode

  @@decode_table = [nil,
    [nil, ?a, ?b, ?c, ?d, ?e],
    [nil, ?f, ?g, ?h, ?i, ?j],
    [nil, ?k, ?l, ?m, ?n, ?o],
    [nil, ?p, ?q, ?r, ?s, ?t],
    [nil, ?u, ?v, ?w, ?x, ?y],
    [nil, ?z, ?., ??, ?!, ' '],
  ]

  def self.decode(str)
    return 'NA' if str.size.odd?
    return 'NA' if str[/[^1-6]/]
    result = ''

    (str.size / 2).times do |index|
      i = str[index * 2].to_i
      j = str[index * 2 + 1].to_i
      ch = @@decode_table[i][j]
      return 'NA' if ch == nil
      result << ch
    end

    result
  end
end

$<.map do |line|
  puts Decode.decode(line.chomp)
end

Measured memory_bytes: 6104
t = [int(input()) for i in range(5)]
sum = 0
amari = [0, 0, 0, 0, 0]

for i in range(5):
    sum += -(-t[i] // 10) * 10
#    print(-(-t[i] // 10) * 10)
    amari[i] = t[i] % 10
    if amari[i] == 0:
        amari[i] = 10

# print(sum)
# print(t)
# print(min(amari))

if min(amari) != 10:
    print(sum - 10 + min(amari))
else:
    print(sum)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define int long long
#define double long double
using namespace std;
const int MOD = 1000000007;
const int INF = 1e15;
using Graph = vector<vector<int>>;

signed main() {
  int N;
  cin >> N;
  string alfa = "abcdefghijklmnopqrstuvwxyz";
  string ans = "";
  while( N > 0 ){
    int A = N%26;
    A--;
    if( A < 0 ) A = 25;
    ans += alfa.at(A);
    if( A == 25 ) N--;
    N /= 26;
  }
  reverse(ans.begin(), ans.end());
  cout << ans << endl;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ul unsigned long int
#define ld long double
#define f(t) for(ll i =0;i<t;i++)
#define vi vector<int>
#define vl vector<ll>
#define pri pair<int,int>
#define mpi map<int,int>
#define prl pair<ll,ll>
#define mp make_pair
#define mpl map<ll,ll>
#define umpl unordered_map<ll,ll>
#define pb push_back
#define ff first
#define ss second
#define MOD 1000000007
#define inf 2e18
#define EPS 1e-3
#define PI 3.1415926535897932385
const double h = 1e-6;
const int MAX_  = 100005;

inline ll mul(ll a, ll b){ return (a * 1ll * b) % MOD; }
inline ll sub(ll a, ll b){ ll c = a - b; if(c < 0) c += MOD; return c; }
inline ll add(ll a, ll b){ ll c = a + b; if(c > MOD) c -= MOD; return c; }
 //////////////////////*********CODE***********/////////////////////
 //////////////////////////////////////////////////////////////////

int main()
 {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;  cin>>n;
    int arr[n];
    f(n)cin>>arr[i];
    ll dp[n];
    //f(n)dp[i] = LONG_MAX;
    dp[0] = 0;
    dp[1] = abs(arr[1]-arr[0]);
    for(int i =2;i<n;i++)
    {
        dp[i] = min(dp[i-1]+abs(arr[i]-arr[i-1]),dp[i-2]+abs(arr[i]-arr[i-2]));
    }
    cout << dp[n-1] << "\n";
    
    return 0;
 }

Measured memory_bytes: 1408
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<algorithm>
#include<cmath>
#include<math.h>
#include<iomanip>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<utility>
#include<stack>
#include<queue>
#include<sstream>
#include<bitset>
#include<cstdio>
#include<stdio.h>
#include<cstring>
#include <stdio.h>
#include <math.h>
#include <cmath>
#include <unordered_map>
using namespace std;
void fast()
{
	std::ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
}
int main()
{
	//in_out_txt();
	fast();
	int a,b,c;
	cin>>a>>b>>c;
	int cnt=0;
	if(a%2==0 && b%2!=0 && c%2!=0)
	{
		cnt++;
		b++;
		c++;
		int mx=max(a,max(b,c));
		cnt+=(mx-a)/2;
		cnt+=(mx-b)/2;
		cnt+=(mx-c)/2;
		cout<<cnt<<'\n';
	}
	else if(a%2!=0 && b%2==0 && c%2==0)
	{
		cnt++;
		b++;
		c++;
		int mx=max(a,max(b,c));
		cnt+=(mx-a)/2;
		cnt+=(mx-b)/2;
		cnt+=(mx-c)/2;
		cout<<cnt<<'\n';
	}
	else if(a%2!=0 && b%2==0 && c%2!=0)
	{
		cnt++;
		a++;
		c++;
		int mx=max(a,max(b,c));
		cnt+=(mx-a)/2;
		cnt+=(mx-b)/2;
		cnt+=(mx-c)/2;
		cout<<cnt<<'\n';
	}
	else if(a%2==0 && b%2!=0 && c%2==0)
	{
		cnt++;
		a++;
		c++;
		int mx=max(a,max(b,c));
		cnt+=(mx-a)/2;
		cnt+=(mx-b)/2;
		cnt+=(mx-c)/2;
		cout<<cnt<<'\n';
	}
	else if(a%2!=0 && b%2!=0 && c%2==0)
	{
		cnt++;
		a++;
		b++;
		int mx=max(a,max(b,c));
		cnt+=(mx-a)/2;
		cnt+=(mx-b)/2;
		cnt+=(mx-c)/2;
		cout<<cnt<<'\n';
	}
	else if(a%2==0 && b%2==0 && c%2!=0)
	{
		cnt++;
		a++;
		b++;
		int mx=max(a,max(b,c));
		cnt+=(mx-a)/2;
		cnt+=(mx-b)/2;
		cnt+=(mx-c)/2;
		cout<<cnt<<'\n';
	}
	else if(a%2==0 && b%2==0 && c%2==0)
	{
		int mx=max(a,max(b,c));
		cnt+=(mx-a)/2;
		cnt+=(mx-b)/2;
		cnt+=(mx-c)/2;
		cout<<cnt<<'\n';
	}
	else if(a%2!=0 && b%2!=0 && c%2!=0)
	{
		int mx=max(a,max(b,c));
		cnt+=(mx-a)/2;
		cnt+=(mx-b)/2;
		cnt+=(mx-c)/2;
		cout<<cnt<<'\n';
	}
	//system("pause");
	return 0;
}

Measured memory_bytes: 256