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

public class Main {
    public static void main(String[] args) {
        try (Scanner scanner = new Scanner(System.in);) {
            String s = scanner.next();
            if (s.charAt(s.length() - 1) == 's') {
                s += "es";
            } else {
                s += "s";
            }

            System.out.println(s);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

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

int main(){
  while(1){
    int x, y;
    cin>>x>>y;

    if(x == 0 && y == 0)break;
    if(x > y) swap(x, y);
    cout<<x<<" "<<y<<endl;
  }

  return 0;
}



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

readline = sys.stdin.buffer.readline
def readstr():return readline().rstrip().decode()
def readstrs():return list(readline().decode().split())
def readint():return int(readline())
def readints():return list(map(int,readline().split()))
def printrows(x):print('\n'.join(map(str,x)))
def printline(x):print(' '.join(map(str,x)))

n,s = readints()
a = readints()

mod = 998244353

z = pow(2,mod-2,mod)

a.sort()

dp = [[0]*(s+1) for i in range(n+1)]
for i in range(n+1):
    dp[i][0] = pow(2,n,mod)

for i in range(1,n+1):
    x = a[i-1]
    for j in range(1,s+1):
        if 0<=j-x:
            dp[i][j] += (dp[i-1][j-x]*z + dp[i-1][j])%mod
        else:
            dp[i][j] += dp[i-1][j]


print(dp[n][s]%mod)




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

// typedef
// -----------------------------------------------------------------------------
typedef long long ll;
typedef long double ld;

// container util
// -----------------------------------------------------------------------------
#define ALL(c)  (c).begin(),(c).end()
#define SZ(c) ((ll)(c).size())
#define MAX(c) *max_element(ALL(c))
#define MIN(c) *min_element(ALL(c))
#define SORT(c) sort((c).begin(),(c).end())

// repetition
// -----------------------------------------------------------------------------
#define FOR(i, a, b) for(ll i= (a); i < (ll)(b); ++i)
#define REP(i, n) FOR(i, 0, n)

// constant
// -----------------------------------------------------------------------------
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
const double EPS = 1e-9;
const double PI = acos(-1.0);

// debug
// -----------------------------------------------------------------------------
#define DUMP(x)  cerr << #x << " = " << (x) << endl


int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
    ll X, K, D; cin >> X >> K >> D;
    ll cnt = abs(X) / D;
    ll rem = K - cnt;
    if (rem < 0) {
        cout << abs(X) - D * K << "\n";
    } else if (rem % 2 == 0) {
        cout << abs(X) - D * cnt << "\n";
    } else {
        cout << D * (cnt + 1) - abs(X)  << "\n";
    }



}

Measured memory_bytes: 3612
#include <iostream>
#include <functional>
#include <algorithm>
#include <utility>
using namespace std;

int main(){
	long int A, B;
	cin >> A >> B;
	long int xa = 0;
	long int xb = 0;
	if(A % 4 == 2 || A % 4 == 1) xa += 1;
	if(B % 4 == 2 || B % 4 == 1) xb += 1;
	long int one = 1;
	long int i = 2;
	while((one << (i-1)) <= A){
		long int checker = one << i;
		long int rest = A % checker;
		if(rest >= checker / 2){
			if(rest % 2 == 0) xa += (one << (i-1));
		}
		i++;
	}
	i = 2;
	while((one << (i-1)) <= B){
		long int checker = one << i;
		long int rest = B % checker;
		if(rest >= checker / 2){
			if(rest % 2 == 0) xb += (one << (i-1));
		}
		i++;
	}
	cout << (xa ^ xb ^ A) << endl;
}

Measured memory_bytes: 256
#include <iostream>

enum struct Panel { none, up, down, right, left };

int main() {
    int h, w;
    while (std::cin >> h >> w && h != 0 && w != 0) {
        std::cin.ignore();

        auto room = new std::pair<Panel, bool>[h * w]();
        std::string s;
        for (int i = 0; i < h; i++) {
            std::getline(std::cin, s);
            for (int j = 0; j < w; j++) {
                switch (s[j]) {
                    case '.': room[i * w + j].first = Panel::none; break;
                    case '^': room[i * w + j].first = Panel::up; break;
                    case 'v': room[i * w + j].first = Panel::down; break;
                    case '>': room[i * w + j].first = Panel::right; break;
                    case '<': room[i * w + j].first = Panel::left; break;
                    default: return EXIT_FAILURE;
                }
            }
        }

        int x = 0, y = 0;
        [&]() {
            while (true) {
                if (room[y * w + x].second) {
                    std::cout << "LOOP";
                    break;
                }
                room[y * w + x].second = true;
                switch (room[y * w + x].first) {
                    case Panel::up: y--; break;
                    case Panel::down: y++; break;
                    case Panel::right: x++; break;
                    case Panel::left: x--; break;
                    case Panel::none: std::cout << x << ' ' << y; return;
                }
            }
        }();
        delete[] room;
        std::cout << std::endl;
    }
}

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

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define in(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << std::endl;
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define out(...) write_to_cout(__VA_ARGS__);

#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

using ll = long long;

using namespace std;

template <typename T>
std::map<T, int> Factorize(T x) {
  std::map<T, int> m;
  for (T i = 2; i * i <= x;) {
    if (x % i == 0) {
      m[i]++;
      x /= i;
    } else {
      ++i;
    }
  }
  if (x > 1) m[x]++;
  return m;
}

int main() {
  in(int, n, m);
  map<int, int> fs = Factorize(m);
  int ans = 1;
  function<void(map<int, int>::iterator, int)> dfs =
      [&](map<int, int>::iterator it, int x) {
        if (it == fs.end()) {
          if (m / x >= n) ans = max(ans, x);
          return;
        }
        rep(i, it->second + 1) {
          dfs(next(it), x);
          x *= it->first;
        }
      };
  dfs(fs.begin(), 1);
  out(ans);
}


Measured memory_bytes: 3608
# include <bits/stdc++.h>
#define INF 1e9
using namespace std;

int main(){
  int N; cin >> N;
  int H[N];
  for(int i=0; i<N; i++){
    cin >> H[i];
  }

  int cnt = 0;
  int ans = 0;
  for(int i = 1; i < N; i++){
    if(H[i] <= H[i-1]){
      cnt += 1;
    }
    else {
      ans = max(ans, cnt);
      cnt = 0;
    }
  }
  ans = max(ans, cnt);

  cout << ans << endl;

}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;

int main(){
	while(1){
		int n; cin >> n;
		if(!n) break;
		vector <pair<double, string> > dic;
		for(int i=0; i<n; i++){
			string name; cin >> name;
			int p, a, b, c, d, e, f, s, m;
			cin >> p >> a >> b >> c >> d >> e >> f >> s >> m;
			double time = a+b+c+(d+e)*m;
			double income = f*m*s-p;
			dic.push_back(make_pair(-(income/time), name));
		}
		sort(dic.begin(), dic.end());
		for(int i=0; i<n; i++){
			cout << dic[i].second << endl;
		}
		cout << "#" << endl;
	}
}


Measured memory_bytes: 3124
#include <map>
#include <set>
#include <cmath>
#include <ctime>
#include <queue>
#include <stack>
#include <vector>
#include <bitset>
#include <cstdio>
#include <cctype>
#include <string>
#include <cstring>
#include <cassert>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std ;

#define rep(i, a, b) for (int (i) = (a); (i) <= (b); (i)++)
#define Rep(i, a, b) for (int (i) = (a) - 1; (i) < (b); (i)++)
#define REP(i, a, b) for (int (i) = (a); (i) >= (b); (i)--)
#define clr(a) memset(a, 0, sizeof(a))
#define Sort(a, len, cmp) sort(a + 1, a + len + 1, cmp)
#define ass(a, sum) memset(a, sum, sizeof(a))

#define ls ((rt) << 1)
#define rs ((rt) << 1 | 1)
#define lowbit(x) (x & -x)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define endl '\n'
#define ENDL cout << endl
#define SZ(x) ((int)x.size())

typedef long long ll ;
typedef unsigned long long ull ;
typedef vector <int> Vi ;
typedef pair <int, int> Pii ;
typedef pair <ll, ll> Pll ;
typedef map <int, int> mii ;
typedef map <string, int> msi ;
typedef map <ll, ll> mll ;

const int N = 100010 ;
const double eps = 1e-8 ;
const int iinf = INT_MAX ;
const ll linf = 2e18 ;
const double dinf = 1e30 ;
const int MOD = 1000000007 ;

inline int read(){
    int X = 0,w = 0 ;
	char ch = 0;
    while(!isdigit(ch)) {w |= ch == '-';ch = getchar();}
    while(isdigit(ch)) X = (X<<3) + (X<<1) + (ch ^ 48),ch = getchar();
    return w ? -X : X;
}

void write(int x){
     if(x < 0) putchar('-'),x = -x;
     if(x > 9) write(x / 10);
     putchar(x%10 + '0');
}

void print(int x) {
	cout << x << endl ;
	exit(0) ;
}

void PRINT(string x) {
	 cout << x << endl ;
	 exit(0) ;
}

void douout(double x){
	 printf("%lf\n", x + 0.0000000001) ;
}

int n, m ;
string ans[N] ;
int cnt[N] ;

struct node {
	int y, p, id ;
} a[N] ;

bool cmp(node a, node b) {
	return a.y < b.y ;
}

bool cmp2(node a, node b) {
	return a.id < b.id ;
}

string work(int x) {
	string ans ;
	int tmp = x ;
	for (int i = 1; i <= 6; i++){
		ans += (tmp % 10 + '0') ;
		tmp /= 10 ;
	}
	reverse(ans.begin(), ans.end()) ;
	return ans ;
}

int main() {
	scanf("%d%d", &n, &m) ;
	for (int i = 1; i <= m; i++) scanf("%d%d", &a[i].p, &a[i].y), a[i].id = i ;
	sort(a + 1, a + m + 1, cmp) ;
	memset(cnt, 0, sizeof(cnt)) ;
	for (int i = 1; i <= m; i++) {
		++cnt[a[i].p] ;
		ans[a[i].id] = work(a[i].p) + work(cnt[a[i].p]) ;
	}
	sort(a + 1, a + m + 1, cmp2) ;
	for (int i = 1; i <= m; i++) cout << ans[i] << endl ;
}

/*
写代码时请注意：
	1.是否要开Long Long？数组边界处理好了么？
	2.实数精度有没有处理？
	3.特殊情况处理好了么？
	4.做一些总比不做好。
思考提醒：
	1.最大值和最小值问题可不可以用二分答案？
	2.有没有贪心策略？否则能不能dp？
*/


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

ll solve() {
    ll N, X;
    cin >> N >> X;
    ll m = 2*N-1;
    if ( X == 1 || X == 2*N-1 ) {
        cout << "No" << "\n";
        return 0;
    }
    cout << "Yes" << "\n";
    vector<ll> A(2*N-1);
    if ( N == 2 ) {
        A[0] = 1, A[1] = 2, A[2] = 3;
    } else {
        queue<int> v;
        if ( X > 2 ) {
            A[N-2] = X-1;
            A[N-1] = X;
            A[N] = X+1;
            A[N+1] = X-2;
            for ( int i = 1; i < X-2; i++ ) v.push(i);
            for ( int i = X+2; i <= 2*N-1; i++ ) v.push(i);
        } else {
            A[N-2] = X+1;
            A[N-1] = X;
            A[N] = X-1;
            A[N+1] = X+2;
            for ( int i = 1; i < X-1; i++ ) v.push(i);
            for ( int i = X+3; i <= 2*N-1; i++ ) v.push(i);
        }
        for ( int i = 0; i < 2*N-1; i++ ) {
            if ( A[i] == 0 ) {
                A[i] = v.front();
                v.pop();
            }
        }
    }
    for ( int i = 0; i < 2*N-1; i++ ) {
        cout << A[i] << "\n";
    }
    return 0;
}

int main() {
    solve();
    return 0;
}

Measured memory_bytes: 3164
def main():
    A,B,K = map(int, input().split())

    a = []
    for i in range(A, A+K):
        if i <= B:
            a.append(i)
            print(i)
    for i in range(B-K+1, B+1):
        if ((i in a)==False)and(i>=A):
            print(i)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
idx(x,y,z) = (x-1)*16 + (y-1)*4 + (z-1) + 1
const mod = 10^9+7

function calc(n::Int64)
    A = zeros(Int128,64,64)

    # ACGT = 1234
    for i=1:4, j=1:4, k=1:4, l=1:4
        if (j==1 && k==3 && l==2) continue end #*AGC
        if (j==1 && k==2 && l==3) continue end #*ACG
        if (j==3 && k==1 && l==2) continue end #*GAC
        if (i==1 && k==3 && l==2) continue end #A*GC
        if (i==1 && j==3 && l==2) continue end #AG*C
        A[idx(i,j,k), idx(j,k,l)] = 1
    end

    ans = A^0
    while n > 0

        if (n%2 == 1)
            ans = (ans * A) .% mod
        end

        A = (A * A) .% mod

        n = n ÷ 2
    end
    return ans
end

function main()
    n = parse(Int, readline())
    A = calc(n)

    ans = 0
    for i=1:4^3
        ans += A[idx(4,4,4),i]
        ans %= mod
    end
    println(ans)
end

main()

Measured memory_bytes: 147332
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
using pil = pair<int, ll>;
using pdd = pair<double, double>;
using uint = unsigned int;
template <typename T>
using Graph = vector<vector<T>>;
const int MOD = 998244353;
const ld PI = acosl(-1);

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

    int A, B, C, D;
    cin >> A >> B >> C >> D;
    vector<vector<ll>> dp(C + 1, vector<ll>(D + 1));
    dp[A][B] = 1;
    for (int i = A; i <= C; ++i) {
        for (int j = B; j <= D; ++j) {
            dp[i][j] += dp[i - 1][j] * j + dp[i][j - 1] * i - dp[i - 1][j - 1] * (i - 1) % MOD * (j - 1);
            dp[i][j] %= MOD;
        }
    }

    if (dp[C][D] < 0)
        dp[C][D] += MOD;
    cout << dp[C][D] << endl;

    return 0;
}


Measured memory_bytes: 73688
### main

n, m = gets.split.map(&:to_i)

sum = n + 1

if m > 0
  rngs = Array.new(m){gets.split.map(&:to_i)}.sort
  #p rngs

  l0, r0 = rngs[0]
  for i in (1...m)
    l1, r1 = rngs[i]
    if r0 < l1
      sum += (r0 - l0) * 2
      l0 = l1
      r0 = r1
    else
      r0 = r1 if r0 < r1
    end
  end
  sum += (r0 - l0) * 2
end

puts sum

Measured memory_bytes: 6112
n,y = map(int, input().split())
ans = "-1 -1 -1"
a = []
for i in range(n+1):
    for j in range(n+1):
        m = n-i-j
        if m>=0 and 10000*i+5000*j+1000*m==y:
            a.append(i)
            a.append(j)
            a.append(m)
            ans = "Yes"
            results = map(str, a)
            answer = " ".join(results)
            print(answer)
            exit()
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
const int INF = 1001001001;

int main() {
int N,K;
cin >> N >> K;
set<int> swe; 
for (int i = 0;i < N;i++) {
    swe.insert(i);
}
for (int i = 0;i < K;i++) {
    int d;
    cin >> d;
    for (int j = 0;j < d;j++) {
        int a;
        cin >> a;
        a--;
        swe.erase(a);
    }
}
cout << swe.size() << endl;



return 0;
}


Measured memory_bytes: 3636
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
using namespace std;
#define ll long long
int main(){
    int a;
    cin >> a;
    if(a<1200)cout <<"ABC";else cout <<"ARC";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>

using namespace std;

#define MAX_N 2500
#define INF 100000000000000

int n, m;
long d[MAX_N];
bool negative[MAX_N];
struct edge {
    long from, to, cost;
};
vector<edge> edges;  // 長さM
// ベルマンフォード法でstartから各点までの最短距離を計算する O(MN)
// checkLoop=trueかつ負のループがある場合は負のループにより最短距離が
// -INFになってしまう点を検出し、negativeに格納
// 要するにnegativeは負のループと繋がってる部分がtrueになる
void bellmanFord(int start, bool checkLoop = false) {
    fill(d, d + n, INF);
    fill(negative, negative + n, false);
    d[start] = 0;
    bool negloop = false;
    for (int i = 1; i < n; i++) {
        for (auto e : edges) {
            if (d[e.from] == INF) continue;
            if (d[e.to] > d[e.from] + e.cost) {
                d[e.to] = d[e.from] + e.cost;
                if (i == n - 1) negloop = true;
            }
        }
    }
    if (!checkLoop || !negloop) return;
    for (int i = 0; i < n; i++) {
        for (auto e : edges) {
            if (d[e.from] == INF) continue;
            if (d[e.to] > d[e.from] + e.cost) {
                d[e.to] = d[e.from] + e.cost;
                negative[e.to] = true;
            } else if (negative[e.from])
                negative[e.to] = true;
        }
    }
}

int main() {
    long p;
    cin >> n >> m >> p;
    for (int i=0; i<m; i++) {
        int a, b;
        long c;
        cin >> a >> b >> c;
        edges.push_back({a-1, b-1, -(c - p)});
    }
    bellmanFord(0, true);
    cout << (negative[n-1] ? -1 : max(-d[n-1], 0l)) << '\n';
    return 0;
}

Measured memory_bytes: 512
import java.util.Scanner;

public class Main {
	static final int MOD = 1000000007;

	static long x = 0;
	static long y = 0;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		int k = Integer.parseInt(sc.next());

		int[] a = new int[n];
		int[] mae = new int[n];
		int[] ato = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = Integer.parseInt(sc.next());
		}

		long cnt = 0;

		count(k);

		for (int i = 0; i < n; i++) {
			for (int j = 0; j < i; j++) {
				if (a[i] > a[j]) {
					mae[i]++;
				}
			}
			for (int j = i + 1; j < n; j++) {
				if (a[i] > a[j]) {
					ato[i]++;
				}
			}

			cnt += ((long) x * mae[i]) % MOD;
			cnt %= MOD;
			cnt += ((long) y * ato[i]) % MOD;
			cnt %= MOD;
			//			System.out.println(cnt + " " + x + " " + y + " " + mae[i] + " " + ato[i]);
		}

		System.out.println(cnt);
		sc.close();
	}

	static void count(int k) {

		x = ((long) (k - 1) * (long) k) / 2;
		x %= MOD;
		y = ((long) (k + 1) * (long) k) / 2;
		y %= MOD;
	}
}

Measured memory_bytes: 26328
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <list>
#include <climits>

using namespace std;
using ll = long long;

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

    vector<int> w(N), v(N);
    int sum_value = 0;

    for(int i = 0; i < N; ++i)
    {
        scanf("%d%d", &w[i], &v[i]);
        sum_value += v[i];
    }

    vector<ll> dp(sum_value + 1, INT_MAX);
    dp[0] = 0;

    for(int item = 0; item <  N; ++item)
    {
        //dp[i] will have weights when value is equal to exactly i
        //For below example dp will have only these values rest INT_MAX: 0 - 0, 30 - 3, 50 - 4, 60 - 5, 80 - 7, 90 - 8
        //Note: this works because values are sorted.
        //N : 3  W: 8
        //w1: 3 v1: 30
        //w2: 4 v2: 50
        //w3: 5 v3: 60
        for(int value =  sum_value; value >= v[item] ; --value)
        {
            dp[value] = min(dp[value], dp[value - v[item]] + w[item]);
        }
    }

    /*
    // To print dp array values
    for(int i = 0; i < sum_value; ++i)
        if(dp[i] != INT_MAX)
            cout << i << "\t";
    cout << "\n";
    */

    ll answer = 0;

    for(int i = 0; i <= sum_value; ++i)
    {
        if(dp[i] <= W)
        {
            answer = max(answer, (ll) i);
        }
    }

    cout << answer << "\n";

    return 0;
}


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

using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(x) (x).begin (),(x).end()
#define sqrt(x) sqrt(abs(x))
#define re return
#define sz(x) ((int)(x).size ())
#define prev PREV
#define next NEXT

using ll = long long;
using ii = pair<int, int>;
using ld = long double;
using D = double;
using vi = vector<int>;
using vii = vector<ii>;
using vvi = vector<vi>;
using vs = vector<string>;

template<typename T> T abs (T x) { re x < 0 ? -x : x; }
template<typename T> T sgn (T x) { re x < 0 ? -1 : (x > 0 ? 1 : 0); }
template<typename T> T sqr (T x) { re x * x; }
template<typename T> T gcd (T a, T b) { re a != 0 ? gcd (b % a, a) : b; }

int n;
int m;
string s;

int main () {
	cin >> s;
	n = sz (s);
	ll ans = 0;
	int cur = 0;
	for (int i = 0; i < n; i++)
		if (s[i] == 'B')
			cur++;
		else
			ans += cur;	
	cout << ans << endl;		
	return 0;
}

Measured memory_bytes: 640
//#pragma GCC optimize("Ofast","unroll-loops","omit-frame-pointer","inline") //Optimization flags
//#pragma GCC option("arch=native","tune=native","no-zero-upper") //Enable AVX
//#pragma GCC target("avx2")  //Enable AVX
#include<bits/stdc++.h>
using namespace std;

#define all(a) begin(a),end(a)
#define F first
#define S second
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 42
#endif

const int mod=1e9+7;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int mul(int a,int b){
  return ((a)*1ll*(b))%mod;
}

void add(int &a,int b){
  a+=b;
  if(a>=mod)a-=mod;
}

int sub(int a,int b){
  a-=b;
  if(a<0){
    a+=mod;
  }
  return a;
}

int powz(int a,int b){
  int res=1;
  while(b){
    if(b&1){
      res=mul(res,a);
    }
    b/=2;
    a=mul(a,a);
  }
  return res;
}

template <typename A, typename B>
istream& operator>>(istream& input,pair<A,B>& x) {
  input>>x.F>>x.S;
  return input;
}

template <typename A>
istream& operator>>(istream& input,vector<A>& x) {
  for(auto& i:x)
    input>>i;
  return input;
}

template<typename A>
ostream& operator<<(ostream& output,vector<A>& x) {
  for(auto& i:x)
    output<<i<<' ';
  return output;
}

template<typename T>
vector<pair<T,int>> getvec(int n){
  vector<pair<T,int>>a(n);
  for(int i=0;i<a.size();i++){
    cin>>a[i].F;
    a[i].S=i;
  }
  return a;
}

const int N=200005;

void solve(){
  int k;
  cin>>k;
  vi a={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  cout<<a[k-1];
    
  
}

signed main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int tc=1;
  //cin>>tc;
  for(int _=0;_<tc;_++){
    // cout<<"Case #"<<_+1<<": ";
    solve();
    if(_!=tc-1){
      cout<<'\n';
    }
  }
}


Measured memory_bytes: 256
class Combination():
    def __init__(self, n, mod=10**9+7):
        self.mod = mod
        self.fac = [1]*(n+1)
        for i in range(1,n+1):
            self.fac[i] = self.fac[i-1] * i % self.mod
        self.invfac = [1]*(n+1)
        self.invfac[n] = pow(self.fac[n], self.mod - 2, self.mod)
        for i in range(n-1, 0, -1):
            self.invfac[i] = self.invfac[i+1] * (i+1) % self.mod
 
    def combination(self, n, r):
        return self.fac[n] * self.invfac[r] % self.mod * self.invfac[n-r] % self.mod
 
    def permutation(self, n, r):
        return self.factorial(n) * self.invfactorial(n-r) % self.mod
 
    def factorial(self, i):
        return self.fac[i]
 
    def invfactorial(self, i):
        return self.invfac[i]

mod = 10**9+7
N,K = map(int,input().split())
ans_ls = [0] * K
c = Combination(N+K)
for i in range(K):
    Blocks = i+1
    #print('-----')
    #print('B:',Blocks)
    if N-K+1>=Blocks:
        Points = c.combination(N-K+1,Blocks)
    else:
        Points = 0
    #print('入れ方：',Points)
    Division = c.combination(K-1,Blocks-1)
    #print('分け方：',Division)
    ans_ls[i] = (Points*Division)%mod

for ans in ans_ls:
    print(ans)

Measured memory_bytes: 74624
/*bismillah ->                                                                                                         << Suirkhanov Meyirlan >>
  GL HF


                                                                                                                      42

    bless my code =)
                                                                                                            NEVER FOLLOW YOUR RULES :D HAHAHAHA
*/


///scanf ("%d%d", &x, &y);
///printf("%d", &a)

#include <bits/stdc++.h>

#define fast ios_base::sync_with_stdio();   cin.tie(0);   cout.tie(0);
#define randoperation srand(time(0));
#define pii pair < int , int >
#define pll pair < ll, ll >
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define fast ios_base::sync_with_stdio();   cin.tie(0);   cout.tie(0);
#define randoperation srand(time(0));

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

const ll N = 1e3 + 7;
const ld pi = 3.14159265359;
const int INF = 1e9 + 7;
const double eps = 1e-9;

const int xi[4] = {-1, 0, +1, 0};
const int yj[4] = {0, +1, 0, -1};
const int xxi[4] = {+1, 0, -1, 0};
const int yyj[4] = {0, -1, 0, +1};

int n, m, q, d[N][N];

int main(){

  //freopen("bridge.in", "r", stdin);
  //freopen("bridge.out", "w", stdout);

  fast
  randoperation;

  ///           ||
  ///start here \/

  cin >> n >> m >> q;

  for(int i = 1; i <= m; i++){
    int l, r;
    cin >> l >> r;
    d[l][r]++;
  }

  for(int i = 1; i <= n; i++){
    for(int j = 1; j <= n; j++){
      d[i][j] += d[i - 1][j] + d[i][j - 1] - d[i - 1][j - 1];
    }
  }

  for(int i = 1; i <= q; i++){

    int l, r;
    cin >> l >> r;

    ll ans = d[r][r] - d[l - 1][r] - d[r][l - 1] + d[l - 1][l - 1];
    cout << ans << '\n';
  }
}


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

using namespace std;

#define ll long long

int main()
{
    ll h;
    cin>>h;
    ll cnt1 = 0;
    ll cnt2 = 0;
    ll i = 1;
    while(h!=1)
    {
        cnt2++;
        cnt1+=i;
        h/=2;
        i*=2;
    }
    cout<<fixed<<setprecision(0)<<cnt1+pow(2,cnt2);
}

Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <math.h>
#include <map>
#include <functional>
#include <iomanip>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <typeinfo>
#define PI 3.14159265359
#define INF 99999999
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(n) rep(i, n)
#define EPS 1e-10
#define pb push_back
#define mp make_pair
typedef long long ll;
using namespace std;
typedef pair<int, int> P;

bool isLeap(int y);
ll gcd(ll a, ll b);
ll lcm(ll a, ll b);
double distanceAB(double xa, double ya, double xb, double yb);
void trace(int A[], int N);

/*
class Target
{
public:
	vector <string> draw(int n)
	{

	}
};
*/


vector<int> G[21];
int color[21];
vector<int> res;
int m, n, x, y;

void dfs(int id)
{
	color[id] = 1;
	rep(i, G[id].size())
	{
		if (color[G[id][i]] == 0) dfs(G[id][i]);
	}
	res.push_back(id);
}

void topologicalSort()
{
	for (int i=1; i<=m; i++)
	{
		if (i == 2) continue;
		if (color[i] == 0) dfs(i);
	}
}


int main()
{
	cin >> m >> n;
	rep(i, n)
	{
		cin >> x >> y;
		if (y == 2) continue;
		G[x].push_back(y);
	}
	
	rep(i, 21) color[i] = 0;
	topologicalSort();
	
	for (int i=res.size()-1; i>=0; i--) cout << res[i] << endl;
	cout << 2 << endl;
	
	return 0;
}


bool isLeap(int y)
{
	return y % 400 == 0
						? true : y % 100 == 0
						? false : y % 4 == 0
						? true : false;
}

ll gcd(ll a, ll b)
{
	return (b > 0) ? gcd(b, a % b) : a;
}

ll lcm(ll a, ll b)
{
	return a / gcd(a, b) * b;
}

void trace(int A[], int N)
{
	REP(N)
	{
		if (i > 0) cout << " ";
		cout << A[i];
	}
	cout << endl;
}

double distanceAB(double xa, double ya, double xb, double yb)
{
	return sqrt((xb-xa)*(xb-xa) + (yb-ya)*(yb-ya));
}

Measured memory_bytes: 1220
unittest
{
	assert( [ "3" ].parse.expand.solve == "1.000000" );
	assert( [ "999" ].parse.expand.solve == "36926037.000000" );
}



import std.conv;
import std.format;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto l = input.front.to!( long );
	return tuple( l );
}

auto solve( long l )
{
	return format( "%0.6f", ( l / 3.0L ) ^^ 3 );
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int digits(int N)
{
  int sum = 0;
  while(N > 0)
  {
    sum += N%10;
    N /= 10;
  }
  return sum;
}

int main()
{
  cout << fixed << setprecision(10);
  int N;
  cin >> N;
  if(N%digits(N)==0)
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
  return 0;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

using namespace std;
using ll = long long;

int main(void)
{
    int n;
    vector<int> a(10000);
    int num = 0;
    int cnt = 1;

    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    for (int i = 0; i < n - 1; i++)
    {
        if (a[i] == a[i + 1])
        {
            cnt++;
        }
        else if (a[i] != a[i + 1])
        {
            num += (cnt / 2);
            cnt = 0;
            cnt++;
        }
    }
    num += (cnt / 2);
    cout << num << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ii pair<int, int>
#define fi first
#define se second

int32_t main()
{
	int n;
	cin >> n;
	for(int i = 0; i < n; i++)
	{
		int x;
		cin >> x;
		if(x % 2 == 0 and (x % 3) and (x % 5)) return puts("DENIED"), 0;
	}
	puts("APPROVED");
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main()
{
  char s[4];
  scanf("%s",&s);
  int i = 0;
  int cnt = 0;
  int max = 0;
  while (s[i])
  {
    if (s[i] == 'R')
      cnt++;
    if (s[i] == 'S')
      cnt = 0;
    if (max < cnt)
      max = cnt;
    i++;
  }
  printf("%d",max);
}

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

namespace ABC083B_SomeSums
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] input = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            int n = input[0];
            int a = input[1];
            int b = input[2];
            int ans = 0;

            for (int i = 1; i <= n; i++)
            {
                int sum = findSumOfDigits(i);
                if (a <= sum && sum <= b)
                {
                    ans += i;
                }
            }
            Console.WriteLine(ans);
        }

        static int findSumOfDigits(int n)
        {
            int sum = 0;
            while (0 < n)
            {
                sum += n % 10;
                n /= 10;
            }
            return sum;
        }
    }
}


Measured memory_bytes: 13396
import sys

s = input()

if s[0] != 'A':
    print('WA')
    sys.exit(0)


count = 0
pos = None
for i in range(2, len(s)-1):
    if s[i] == 'C':
        pos = i
        count += 1

if count != 1:
    print('WA')
    sys.exit(0)

for i in range(1, len(s)):
    if i != pos and s[i].isupper():
        print('WA')
        sys.exit(0)

print('AC')


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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////
ll N, K, A[202020];
ll s[202020];
ll mk[202020],mk2[202020];
ll nxt[202020];
ll i,j,k;
int main(){
    scanf("%lld%lld", &N,&K);
    fornum(i,0,N){
        scanf("%lld", &A[i]);
    }
    
    fornum(i,0,202020){
        mk[i] = -1;
    }
    i = 0;
    j = 0;
    while(j<N){
        if(mk[A[i]]==-1){
            mk[A[i]] = i;
        }else{
            ll b = mk[A[i]];
            
            if(nxt[b]!=0){
                i = (i + 1) % N;
                continue;
            }
            nxt[b] = (i + N - b) % N;
            //printf("%lld,%lld:%lld\n", i, A[i], nxt[b]);
            if(nxt[b]==0)
                nxt[b] = N;
            
            mk[A[i]] = i;
            j++;
        }
        i = (i + 1) % N;
    }
    //fornum(i,0,N){
    //    printf("%lld ", nxt[i]);
    //}
    
    j = 0;
    do{
        j += nxt[j % N];
        j++;
    } while (j % N != 0);
    //printf("\n%lld",j);
    K %= j / N;
    j = 0;
    while(j+nxt[j%N]+1<=K*N){
        j += nxt[j % N]+1;
    }
    //printf(" %lld\n", j);
    if(j==K*N){
        return 0;
    }
    j %= N;
    i = 0;
    fornum(j,j,N){
        if(mk2[A[j]]==0){
            mk2[A[j]] = 1;
            s[i++] = A[j];
        }else{
            do{
                mk2[s[--i]] = 0;
            } while (s[i] != A[j]);
        }
    }
    fornum(j,0,i){
        printf("%lld ", s[j]);
    }
    return 0;
}

Measured memory_bytes: 9344
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define inf LLONG_MAX>>2
#define MAX 1000000
#define mod 1000000007
#define pb push_back
#define f(i,a,n,x) for ((i)=(a);(i)<(n);(i)+=(x))
#define fd(i,a,n,x) for ((i)=(a);(i)>=(n);(i)-=(x))
#define fi first
#define se second
#define mk make_pair
#define pi pair
#define vt vector
using namespace std;
void read(vt<ll> &a,ll n){ll i,temp;f(i,0,n,1){cin>>temp;a.pb(temp);}}
ll count(ll x){
    ll c=0;
    while(x){
        c++;
        x/=10;
    }
    return c;
}
void solve(){
    ll n,i,ans=inf;
    cin>>n;
    f(i,1,100001,1)
        if ((i*(n/i))==n)
            ans=min(ans,max(count(i),count(n/i)));
    cout<<ans<<endl;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll t=1;
    //cin>>t;
    while(t--)
        solve();
    return 0;
}

Measured memory_bytes: 3612
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<iostream>
#include<string>

using namespace std;


void Solution()
{
    int n;
    int weight;
    int num = 1;
    
    while(cin>>weight, weight)
    {
        cin >> n;
        
        int dp[1000]={0};
        
        int v,w;
        char comma;
        
        while(n--)
        {
            cin>>v>>comma>>w;
            
            for(int i = weight - w; i >= 0; i--)
            {
                dp[i + w] = max(dp[i + w], dp[i]+v);
            }
        }
        
        int mi = weight;
        
        for(int i = weight; i >= 0; i--)
        {
            if(dp[i] != dp[mi])
            {
                cout << "Case " << num++ << ":\n";
                cout << dp[mi] << "\n" << mi << "\n";
                break;
            }
            
            mi = i;
        }
    }
}

int main()
{
    Solution();
    return 0;
}

Measured memory_bytes: 1156
import java.util.*;

class Main{
    public static void main (String[] args){
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        long ans = n / 11 * 2;
        if(n % 11 != 0 && n % 11 > 6){
            ans += 2;
        }else if(n % 11 != 0){
            ans++;
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define all(x) (x).begin(),(x).end()
typedef long long int ll;
using namespace std;
int n;
vector<int > a;
bool check(int s){
  int ind = 0;
  int jl = 0;
  bool flag = false;
  for(int i = 1; i <= n - s; i++){
    flag = false;
    for(int j = jl; j < n; j++){
      if(a[j] == i){
	jl = j;
	flag = true;
	break;
      }
    }
    if(!flag){
      return false;
    }
  }
  return true;
}
int main()
{
  cin >> n;
  a.resize(n);
  REP(i,n){cin >> a[i];}
  int count = 0;
  int l = 0;
  int r = n - 1;
  if(check(l)){
    // cout << "ALL" << endl;
    cout << 0 << endl;
    return 0;
  }
  if(!check(r)){
    // cout << "NO" << endl;
    cout << -1 << endl;
    return 0;
  }
  int c;
  while(true){
    c = (l + r)/2;
    bool test = check(c);
    // cout <<"l, c, r, check(c) = "<< l << "," << c << "," << r <<", "<< test <<endl;
    if(test){
      r = c;
    }else{
      l = c;
    }
    if(r - l == 1){
      break;
    }
  }
  if(check(l)){
    cout << l << endl;
  }else{
    cout << r << endl;
  }
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ll long long int
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define put(x) cout << x << endl;
using namespace std;
int main()
{
    int n, m;
    cin >> n >> m;
    vector<int> a(m);
    rep(i, m) cin >> a[i];
    int sum = 0;
    rep(i, m) sum += a[i];
    if (sum > n) {
        put(-1)
    }
    else {
        put(n - sum);
    }
    return 0;
}

Measured memory_bytes: 3604
#include <iostream>
#include <vector>
#include <iomanip>
using namespace std;
typedef long long ll;

ll W,H,x,y;
int main(){
    cin >> W >> H >> x >> y;
    cout << fixed;
    cout << setprecision(10) << 1.0*W/2.0*H << " ";
    if(2*x==W && 2*y==H) cout << 1 << endl;
    else cout << 0 << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sn = new Scanner(System.in);
        while(sn.hasNext()) {
            int a = sn.nextInt();
            int b = sn.nextInt();
            int k = a + b;
            System.out.println((k + "").length());
        }
    }
}

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

int main() 
{
	int a = 0, b = 0;
	cin >> a >> b;
	int c = a * b;
	int e = a * b * c;
	if(e % 2 == 0)
	{
		cout << "No" << endl;
	}
	else
	{
		cout << "Yes" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
// Hail god Yato
 
#include <bits/stdc++.h> 
using namespace std;
 
#define hs ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
const ll MOD = 1000000007;
const ll INF = 1e18;
const ll MAX = 100001;
//
//
void solve(){
    int n, m;
    cin>>n>>m;
    vector<vector<int>> vec(n, vector<int>(m));
    for(int i = 0; i < n; i++)
        for(int j = 0; j < m; j++)
            cin>>vec[i][j];

    vector<vector<int>> store;
    int size = 0;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < m-1; j++){
            if((vec[i][j]&1) && j != m-1){
                ++size;
                store.push_back({i, j, i, j+1});
                --vec[i][j];
                ++vec[i][j+1];
            }
        }
        if((vec[i][m-1]&1) && i != n-1){
            ++size;
            store.push_back({i, m-1, i+1, m-1});
            --vec[i][m-1];
            ++vec[i+1][m-1];
        }
    }
    cout<<size<<"\n";
    for(auto itr : store){
        cout<<itr[0]+1<<" "<<itr[1]+1<<" "<<itr[2]+1<<" "<<itr[3]+1<<"\n";
        // cout<<"\n";
    }
}
int main(){ 
        hs;
        ll t;
        t=1;
        // cin>>t;
        for (int i=1; i<=t; i++){
                //cout<<"Case #"<<i<<": ";
                solve();
         }
        return 0; 
}

Measured memory_bytes: 11084
#include <iostream>
#include <string>
#include <queue>
using namespace std;

typedef pair<int,int> P;

int main(){
	int h,w,cnt = 0;
	bool used[8][8] = {};
	string field[8];
	cin >> h >> w;
	for(int i = 0;i < h;i++) {
		cin >> field[i];
		for(int j = 0;j < w;j++){
			if(field[i][j] == '#') cnt++;
		}
	}
	if(field[0][0] != '#' || cnt != h + w - 1){
		cout << "Impossible" << endl;
		return 0;
	}
	queue<P> que;
	que.push(P(0,0));
	while(!que.empty()){
		P p = que.front();que.pop();
		int x = p.first,y = p.second;
		if(used[x][y]) continue;
		used[x][y] = true;
		if(x != h - 1){
			if(field[x + 1][y] == '#' && !used[x + 1][y]) {
				que.push(P(x + 1,y));
			}
		}
		if(y != w - 1){
			if(field[x][y + 1] == '#' && !used[x][y + 1]) {
				que.push(P(x,y + 1));
			}
		}
	}
	if(used[h - 1][w - 1]) cout << "Possible" << endl;
	else cout << "Impossible" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <string>

int main(int argc, char* argv[]) {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);

  /* */
  std::string str;
  std::cin >> str;

  std::string state;
  for (auto c : str) {
    if (c == 'B') {
      if (state.length() > 0) state.pop_back();
    } else {
      state.push_back(c);
    }
  }
  std::cout << state << std::endl;
  /* */

  return EXIT_SUCCESS;
}


Measured memory_bytes: 256
/*   In The Name Of God   */
// Hunt...
/*
ID: alimora2
LANG: C++11
TASK: PROB
*/
#include <bits/stdc++.h>

#define sqr(A) (A) * (A)
using namespace std;
typedef long long ll;

const int maxn = 1e5;
ll a[maxn], dp[2][maxn], p[2];

int main() {
	ios::sync_with_stdio(false), cin.tie(0);
	int n;
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	if (a[0] > 0) {
		dp[0][0] = 0, p[0] = a[0];
		dp[1][0] = a[0] + 1, p[1] = -1;
	}
	if (a[0] < 0) {
		dp[1][0] = 0, p[1] = a[0];
		dp[0][0] = abs(a[0]) + 1, p[0] = 1;
	}
	if (a[0] == 0) {
		dp[0][0] = 1, p[0] = 1;
		dp[1][0] = 1, p[1] = -1;
	}
	for (int i = 1; i < n; i++) {
		int d0, d1, p0 = p[0], p1 = p[1];
		if (p1 + a[i] > 0)
			d0 = 0, p[0] = p1 + a[i];
		else if (p1 + a[i] == 0)
			d0 = 1, p[0] = 1;
		else
			d0 = abs(p1 + a[i]) + 1, p[0] = 1;
		if (p0 + a[i] < 0)
			d1 = 0, p[1] = p0 + a[i];
		else if (p0 + a[i] == 0)
			d1 = 1, p[1] = -1;
		else
			d1 = p0 + a[i] + 1, p[1] = -1;
		dp[0][i] = dp[1][i - 1] + d0;
		dp[1][i] = dp[0][i - 1] + d1;
	}
	cout << min(dp[0][n - 1], dp[1][n - 1]) << endl;
}

Measured memory_bytes: 2560
import scala.io.StdIn

object Main extends App {

  val n = StdIn.readLine().toInt
  val a = StdIn.readLine().split(" ").map(_.toInt)
  
  val r = a.foldLeft(0){ (acc, x) =>
    def loop(xm: Int, cnt: Int): Int = {
      if(xm % 2 != 0 || xm / 2 == 0) cnt
      else loop(xm/2, cnt+1)
    }
    acc + loop(x, 0)
  }
  
  println(r)
  
}


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

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;

#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

int main(){
  fastIO;
  int n, m;
  cin >> n >> m;
  int li = 1, ri = n;
  int l, r;
  for(int i = 0 ; i < m ; i ++ ){
    cin >> l >> r;
    li = max(li, l);
    ri = min(ri, r);
  }
  cout << max(0,ri-li+1);
  return 0;
}

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

int main()
{
    int n, k;
    string s;
    cin >> n >> s >> k;
    for (int i = 0; i < n; i++)
    {
        if (s[k - 1] == s[i])
        {
            cout << s[k - 1];
        }
        else
        {
            cout << "*";
        }
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
N = 13
while True:
    try:
        A = list(map(int,input().split(',')))
    except EOFError:
        break
    flag = False
    for i in range(1,N + 1):
        if A.count(i) == 4:
            flag = True
            print('four card')
            break
    if flag:
        continue
    for i in range(1,N + 1):
        for j in range(1,N + 1):
            if i == j:
                continue
            if A.count(i) == 3 and A.count(j) == 2:
                flag = True
                print('full house')
                break
        if flag:
            break
    if flag:
        continue
    for i in range(1,11):
        cnt = 0
        for j in range(0,5):
            if i + j == 14:
                cnt += A.count(1) > 0
            else:
                cnt += A.count(i + j) > 0
        if cnt == 5:
            flag = True
            print('straight')
            break
    if flag:
        continue
    for i in range(1,N + 1):
        if A.count(i) == 3:
            flag = True
            print('three card')
            break
    if flag:
        continue
    for i in range(1,N + 1):
        for j in range(1,N + 1):
            if i == j:
                continue
            if A.count(i) == 2 and A.count(j) == 2:
                flag = True
                print('two pair')
                break
        if flag:
            break
    if flag:
        continue
    for i in range(1,N + 1):
        if A.count(i) == 2:
            flag = True
            print('one pair')
            break
    if flag:
        continue
    print('null')

Measured memory_bytes: 7592
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <random>
#include <cmath>
#include <iomanip>
#include <climits>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>
#include <new>
#include <typeinfo>
#include <iterator>

typedef long long ll;
typedef unsigned long long ull;
constexpr ll mop = 1000000007;
constexpr ll mop2 = 998244353;

using namespace std;

int main() {
	ll x, n;
	cin >> x >> n;
	vector <bool> lis;
	lis.resize(102, true);
	for (ll i = 1; i <= n; i++) {
		ll tmp;
		cin >> tmp;
		lis[tmp] = false;
	}
	ll ansNum = INT64_MAX;
	ll ansDis = INT64_MAX;
	for (ll i = 0; i <= 101; i++) {
		if (lis[i] == true) {
			ll dis = abs(x - i);
			if (dis < ansDis) {
				ansDis = dis;
				ansNum = i;
			}
		}
	}
	cout << ansNum << endl;

}

Measured memory_bytes: 3632
#include<iostream>
#include<algorithm>
using namespace std;
#define MAXN 100006
typedef long long ll;
ll A[MAXN] , B[MAXN] , idx[MAXN];
ll n , resa , resb;
bool cmp( ll x,ll y ) {
	return ( A[x]+B[x] ) > ( A[y]+B[y] );
}
int main(){
	//freopen("input","r",stdin);
  	cin >> n;
	for( ll i = 1 ; i <= n ; ++ i )
		scanf("%lld%lld",&A[i] , &B[i]) , idx[i]=i;
	sort( idx+1 , idx+1+n , cmp );
	ll i = 1 , j = 2;
	while( j<=n ) 
		resa += A[idx[i]],
		resb += B[idx[j]],
		i+=2 , j+=2;
	if( i == n ) resa += A[idx[i]] ;
	cout << resa - resb;
}


Measured memory_bytes: 2560
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

import static java.lang.Integer.parseInt;

/**
 * The Oldest Site
 */
public class Main {

	static final int MAX = 5000;

	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;
		String[] words;

		while ((line = br.readLine()) != null && !line.isEmpty()) {

			int n = parseInt(line);
			if (n == 0) break;

			int[][] points = new int[n][2];
			boolean[][] grid = new boolean[MAX + 1][MAX + 1];
			
			for (int i = 0; i < n; i++) {
				line = br.readLine();
				int x, y;
				x = parseInt(line.substring(0, line.indexOf(' ')));
				y = parseInt(line.substring(line.indexOf(' ') + 1));

				points[i][0] = x;
				points[i][1] = y;
				grid[y][x] = true;
			}

			//solve
			int max = 0;
			for (int i = 0; i < n; i++) {
				for (int j = i + 1; j < n; j++) {

					int p1x, p1y, p2x, p2y, dx, dy;
					p1x = points[i][0];
					p1y = points[i][1];
					p2x = points[j][0];
					p2y = points[j][1];
					dx = p1x - p2x;
					dy = p1y - p2y;

					//
					{
						int p3x, p3y, p4x, p4y;
						p3x = p1x - dy;
						p3y = p1y + dx;
						p4x = p2x - dy;
						p4y = p2y + dx;
						if (0 <= p3x && p3x <= MAX
								&& 0 <= p3y && p3y <= MAX
								&& 0 <= p4x && p4x <= MAX
								&& 0 <= p4y && p4y <= MAX
								&& grid[p3y][p3x]
								&& grid[p4y][p4x]) {
							max = Math.max(max, dx * dx + dy * dy);
						}
					}

					//
					{
						int p3x, p3y, p4x, p4y;
						p3x = p1x + dy;
						p3y = p1y - dx;
						p4x = p2x + dy;
						p4y = p2y - dx;
						if (0 <= p3x && p3x <= MAX
								&& 0 <= p3y && p3y <= MAX
								&& 0 <= p4x && p4x <= MAX
								&& 0 <= p4y && p4y <= MAX
								&& grid[p3y][p3x]
								&& grid[p4y][p4x]) {
							max = Math.max(max, dx * dx + dy * dy);
						}
					}
				}
			}
			System.out.println(max);
		}//end while
	}//end main
}

Measured memory_bytes: 127960