akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <unordered_set>
using namespace std;
#define int long long
#define pb push_back
#define endl "\n";
#define deb1(x) cout << #x << ": " << x << endl
#define deb2(x, y) cout << #x << ": " << x << " | " << #y << ": " << y << endl
#define fast                      \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0);
#define printclock cerr << "Time : " << 1000 * (ld)clock() / (ld)CLOCKS_PER_SEC << "ms\n";
#define vii vector<int>
#define pii pair<int, int>
#define prec(n) fixed << setprecision(n)
#define mp make_pair
#define all(a) a.begin(), a.end()
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define MOD LLONG_MAX
inline void get(vector<int> &arr, int n)
{
    int a;
    for (int i = 0; i < n; i++)
    {
        cin >> a;
        arr.push_back(a);
    }
}
inline void print(vector<int> &arr, int n)
{
    for (int i = 0; i < n; i++)
        cout << arr[i] << " ";
    cout << endl;
}
int dp[100005];
int n, w;
vector<pair<int, int>> knap(101);
void solve()
{
    rep(i, 1, n + 1)
    {
        auto item = knap[i];
        for (int weight = w - (item.first); weight >= 0; weight--)
        {
            dp[weight + item.first] = max(dp[weight + item.first], dp[weight] + item.second);
        }
    }
}
int32_t main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
    fast;
    int t;
    t = 1;
    while (t--)
    {
        cin >> n >> w;
        int a, b;
        rep(i, 1, n + 1)
        {
            cin >> a >> b;
            knap[i] = mp(a, b);
        }
        memset(dp, 0, sizeof(dp));
        solve();
        int ans = -1;
        rep(i, 1, w + 1) ans = max(ans, dp[i]);
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 4388
def is_kaibun(string):
    isk = True
    length = len(string)
    for i in range(length // 2):
        if string[i] != string[length - 1 - i]:
            isk = False
            break
    return isk

s = input()
len_s = len(s)
if is_kaibun(s[0:(len_s // 2)]) and is_kaibun(s):
    print('Yes')
else:
    print('No')


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

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef pair<LL, LL> PLL;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

struct Edge{
  int to, cost;

  Edge(int t, int c): to(t), cost(c)
  {}
  bool operator>(const Edge& rhs) const{
	return cost > rhs.cost;
  }
  bool operator<(const Edge& rhs) const{
	return cost < rhs.cost;
  }

};
typedef vector< vector<Edge> > Graph;
void add_edge(Graph& graph, int u, int v, int cost){
  graph[u].push_back(Edge(v,cost));
  graph[v].push_back(Edge(u,cost));
}

int N, K;
const int MAX = 2010;
const int LOG_MAX = log2(MAX);
int depth[MAX];
int num[MAX];
int parent[LOG_MAX][MAX];
Graph G(MAX);
// number graph with root. root is first given node
// suppose depth < 0
void dfs(int node, int p = -1, int d = 0)
{
  if(depth[node] >= 0) return;
  depth[node] = d;
  parent[0][node] = p;
  num[node] = 1;
  for(int i=0;i<SZ(G[node]);++i){
	if(G[node][i].to == p) continue;
	dfs(G[node][i].to, node, d+1);
	num[node] += num[G[node][i].to];
  }
}

void init(){
  fill(depth, depth+MAX, -1);
  dfs(0);
  for(int i=0;i+1<LOG_MAX;++i){
	for(int v=0;v<N;++v){
	  if(parent[i][v] == -1) parent[i+1][v] = -1;
	  else parent[i+1][v] = parent[i][parent[i][v]];
	}
  }
}

int LCA(int u, int v){
  if(depth[u] > depth[v]) swap(u, v);
  //depth[u] <= depth[v]
  for(int i=0;i<LOG_MAX;++i)
	if((depth[v] - depth[u]) >> i & 1)
	  v = parent[i][v];
  if(u == v) return u;

  for(int i=LOG_MAX-1;i>=0;--i){
	if(parent[i][u] != parent[i][v]){
	  u = parent[i][u];
	  v = parent[i][v];
	}
  }
  return parent[0][u];
}

int dist(int u, int v){
  return depth[u] + depth[v] - depth[LCA(u,v)];
}

int dfs2(int u, int p, int d){
  int res = 0;
  if(d < 0){
	++res;
  }
  
  for(auto& e: G[u]){
	if(e.to == p) continue;
	res += dfs2(e.to, u, d-1);
  }
  return res;
}

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

  cin >> N >> K;
  REP(i,N-1){
	int u, v; cin >> u >> v;
	--u, --v;
	add_edge(G, u, v, 1);
  }
  //init();

  int ans = N;
  if(K % 2 == 0){
	REP(u,N){
	  ans = min(ans, dfs2(u, -1, K/2));
	}
  }
  else{
	REP(u,N){
	  for(auto& e:G[u]){
		ans = min(ans, dfs2(u, e.to, K/2) + dfs2(e.to, u, K/2));
	  }
	}
  }
  cout << ans << endl;
  
  return 0;
}


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

const int MAX = 10; // 横
const int MAX2 = 101; // 高さ
const int MOD = 1000000007; // 今回使う余り
int main() {
	int H, W, K;
	cin >> H >> W >> K;
	
	int64_t fib[MAX]; // あみだくじの場合、長さnはfib(n+1)を参照 ちょっと変則的なfibだけどね、0, 0, 1, 2, 3, 5, 8, 13, 21, ...ってなるので
	fib[1] = fib[2] = 1;
	for (int i = 3;i <= W + 1;++ i) fib[i] = fib[i - 1] + fib[i - 2];
	fib[0] = 0;
	
	int64_t dp[MAX2][MAX]; // 番兵付きなので間違えないように！dp[i][j]は高さiにおける左からj番目に辿れる組み合わせ
	for (int i = 0;i <= H;++ i) for (int j = 0;j <= W + 1;++ j) dp[i][j] = 0;
	dp[0][1] = 1;
	for (int i = 1;i <= H;++ i) {
		for (int j = 1;j <= W;++ j) {
			dp[i][j] = dp[i - 1][j - 1] * fib[j - 1] * fib[W - j + 1] + dp[i - 1][j] * fib[j] * fib[W - j + 1] + dp[i - 1][j + 1] * fib[j] * fib[W - j];
			dp[i][j] %= MOD; // 忘れずに！
		}
	}
	cout << dp[H][K];
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり
また、コンテスト後に https://31536000.hatenablog.com/ で解説していると思うので、良かったら読んでねー

上から考えていこう
まず、高さ1の時点での1の存在は、1-2に線が引かれていない場合は1に行き、その組み合わせは2からWまでの全ての横線を引く組み合わせに等しい
そして、1-2に線が引かれていれば2に行き、その組み合わせは3からWまでの全ての横線を引く組み合わせに等しい

……a-b間における組み合わせは先に計算すると良さそうなのでまず考えてみよう
平行移動しても同じなので、b-a=xとする長さを考えてf(x)で定義しよう
まず、f(0)=1, f(1)=2(引く/引かない)
f(2)=f(1)(引かない場合)+f(0)(引いた場合)
以下、f(n)=f(n-1)+f(n-2)と導出できるので、これはフィボナッチ数列になるね

次に、今辿っている位置がxにある時の次の組み合わせを考えよう
・x-1に移動する組み合わせ
・xに移動する組み合わせ
・x+1に移動する組み合わせ
これ以外はあり得ないので、これだけ考えれば良いね
まず、x-1に移動する場合、(x-1)-xにあみだが引かれたので、(x-2)-(x-1)とx-(x+1)にはあみだが引かれない
よって、この組み合わせは1-(x-2)間×(x+1)-W間の組み合わせ、よってf(x-2)*f(W-x)となる
次にxに移動する場合は(x-1)-xとx-(x+1)にはあみだが引かれないので、f(x-1)*f(W-x)となるね
最後にx+1に移動する場合はx-(x+1)にあみだが引かれ、(x-1)-xと(x+1)-(x+2)にはあみだが引かれないのでf(x-1)*f(W-x-1)となる
あ、f(-1)=0で良いよ、長さが負とかありえないので

ということは、これであみだくじを1個下に動く遷移がO(W)でできたので答えはO(HW)、間に合うね
*/

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

using namespace std;
 
//#define int long long
using ll = long long;
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(ll i=0;i<n;i++)
#define reps(i,n) for(ll i=0;i<=n;i++)
#define PI 3.14159265358979323846264338327950L

ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
 
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

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

ll lcm(ll x, ll y) {
    return x / gcd(x, y) * y;//先に割り算をして掛けられる数を小さくして掛け算を行う
}

int main(){
    ios_base::sync_with_stdio(false);
    ll a,b;
    cin >> a >> b;
    cout << lcm(a,b) << endl;
    return 0;
}


Measured memory_bytes: 3568
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int w = sc.nextInt();

		for (int i = 0; i < s.length(); i += w) {
			System.out.print(s.substring(i, i + 1));
		}

		sc.close();
	}

}


Measured memory_bytes: 21844
#include <stdio.h>

int main(void)
{
  unsigned int A[1000], B[1000];
  unsigned int num;
  unsigned int keta;
  unsigned int i, j;

  for (i = 0;;i++){
    if (scanf("%d", &A[i]) == EOF)
      break;
    scanf("%d", &B[i]);
  }

  for (j = 0; j < i; j++){
    num = A[j] + B[j];
    for (keta = 0; num; keta++){
      num /= 10;
    }
    printf("%d\n", keta);
  }
  return 0;
}

Measured memory_bytes: 604
n = int(input())
a = list(map(int, input().split()))
plus, minus = [], []
for x in a:
    if x < 0: minus.append(x)
    else: plus.append(x)

if plus and minus:
    print(sum(map(abs, a)))
    p = plus[0]
    for x in minus[1:]:
        print(p, x)
        p -= x
    
    m = minus[0]
    for x in plus[1:]:
        print(m, x)
        m -= x
    
    print(p, m)

if not plus:
    minus.sort(reverse=True)
    m = minus[0]
    print(-(sum(minus) - m * 2))
    for x in minus[1:]:
        print(m, x)
        m -= x

if not minus:
    plus.sort()
    p = plus[0]
    print(sum(plus) - p * 2)
    for x in plus[2:]:
        print(p, x)
        p -= x
    print(plus[1], p)


Measured memory_bytes: 14264
#include<bits/stdc++.h>
using namespace std;
    static const double pi = 3.141592653589793;
 typedef pair<int64_t,int64_t> P;
#define rep(i, n) for (int i = 0; i < (n); i++)

int main() {
string a;
  cin>>a;
  int64_t v=a.size();
  if(v%2!=0)  cout<<"No";
  else {
    int y=0;
  for(int i=0;i<v;i=i+2)
  {
  if(a.at(i)!='h') y=1;
   if(a.at(i+1)!='i') y=1;
  }
  if(y==1) cout<<"No";
    else cout<<"Yes";
  }
  
}
 

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

using namespace std;

int main(){
  int n;
  std::cin >> n;

  vector<int> bucket(1000000, 0);
  for(int idx = 0; idx < n;  idx++){
    int input;
    std::cin >> input;
    bucket[input] += 1;
  }

  int ans = 0;
  for(int idx = 2; idx < bucket.size(); idx++){
    int num = bucket[idx - 2] + bucket[idx - 1] + bucket[idx];
    if(ans < num){
      ans = num;
    }
  }

  std::cout << ans << '\n';

  return 0;
}


Measured memory_bytes: 4856
#include<iostream>
#include<stdio.h>
#include<stdlib.h>

using namespace std;
int main(){
	int meter[10];
	int a,i,j,temp;
	char str[1024];
	for(i = 0;i < 10;i++){
		scanf("%d",&a);
		meter[i] = a;
	}


	for (i = 0; i < 10; i++) {
        for (j = 9; j > i; j--) {
            if (meter[j - 1] < meter[j]) {  
                temp = meter[j];        
                meter[j] = meter[j - 1];
                meter[j - 1]= temp;
            }
          }
     }     
	
	for(i = 0;i < 3;i++){
	printf("%d\n",meter[i]);
	}

    return 0;
}

Measured memory_bytes: 1188
n,m = map(int,input().split())
nlis = [0] * n
ac = 0
wa = 0
for _ in range(m):
    p, s = input().split()
    p = int(p) -1
    if nlis[p] == -1:
        continue
    if s == "WA":
        nlis[p] += 1
    else:
        ac += 1
        wa += nlis[p]
        nlis[p] = -1
print(ac,wa)

Measured memory_bytes: 3956
'use strict';
process.stdin.on('data', function(chunk) {
  var inputs = chunk.toString().trim().split('\n');
  for (var i = 0; i < inputs.length; i++){
  	if (inputs[i] === '0 0'){
  		break;
  	}
  	var cols = inputs[i].split(' ').map(Number);
  	console.log(
  		cols.sort(function(a,b){
  			return a-b;
  		}).join(' ')
  		);
  } 
 });
process.stdin.resume();
process.stdin.setEncoding('utf8');

Measured memory_bytes: 19544
n, m, k = map(int, input().split())
MOD = 998244353

def fn(n, m):
  return (m*pow(m-1, n-1, MOD))%MOD

fact = [1, 1]
factinv = [1, 1]
inv = [0, 1]
for i in range(2, n):
  fact.append((fact[-1]*i) % MOD)
  inv.append((-inv[MOD % i] * (MOD // i) % MOD))
  factinv.append((factinv[-1] * inv[-1]) % MOD)
  
def nCr(n, r):
    return fact[n] * factinv[r] * factinv[n-r] % MOD

ans = fn(n, m)
for i in range(1, k+1):
  ans += nCr(n-1, i)*fn(n-i, m)
  ans %= MOD
print(ans)

Measured memory_bytes: 33160
/*
AizuOnline A0022
Maximum Sum Sequence
*/
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>

char conv(char c)
{
  if(islower(c))
    return(toupper(c));
  else
    return(c);
}
main()
{
  char buffer[1000];
  char buffer2[1000];
  int i;
  
  fgets(buffer,1000,stdin);

  for(i=0;i<1000;i++)
    {
      buffer2[i]=conv(buffer[i]);
      if(buffer[i] =='\0')
        break;
    }

printf("%s",buffer2);

return(0);
}

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

int main() {
  char s;
  cin >> s;
  if (s == 'S')
    cout << "Cloudy" << endl;
  else if (s == 'C')
    cout << "Rainy" << endl;
  else
    cout << "Sunny" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int MAX_N=1e6;
int seg_tree[2*MAX_N+5],n;
void build()
{
for(int i=n-1; i>0; --i)
seg_tree[i]=__gcd(seg_tree[i<<1],seg_tree[i<<1|1]);
}
void modify(int pos,int val)
{
for(seg_tree[pos+=n]=val; pos>1; pos>>=1)
seg_tree[pos>>1]=__gcd(seg_tree[pos],seg_tree[pos^1]);
}
int query(int l,int r)
{
int ans(1);
for(l+=n,r+=n; l<r; l>>=1,r>>=1)
{
if(l&1)
ans=__gcd(ans,seg_tree[l++]);
if(r&1)
ans=__gcd(ans,seg_tree[--r]);
}
return ans;
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int a,b,c;
cin>>a>>b>>c;
cout<<min({a,b,c})+(a+b+c-min({a,b,c})-max({a,b,c}));
}

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

#define ll long long
#define ull unsigned long long

using namespace std;

int main() {
	string s, t;
	cin >> s >> t;

	int ans = 0;
	for (int ii = 0; ii < 3; ++ii){
		if (s[ii] == t[ii]){
			ans++;
		}
	}



	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <cstdlib>
#include <cmath>

typedef long long ll;

using namespace std;

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	
	for (int i = 0; i < 10; i++) {
		 c = a * c - b;
		 cout << c << endl;
	}
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
using namespace std;
using ll = int64_t;
using vi = vector<int>;
using vvi = vector<vi>;

int main() {
    int n;
    cin >> n;
    vector<pair<int, int> > X(n);
    rep(i, n) {
        cin >> X[i].first >> X[i].second;
    }

    map<pair<int, int>, int> con;
    rep(i, n) {
        rep(j, n) {
            if(i == j) continue;
            int x, y;
            x = X[i].first - X[j].first;
            y = X[i].second - X[j].second;
            pair<int, int> k = make_pair(x, y);
            con[k]++;
        }
    }

    int ma=0;
    for(auto i:con) {
        ma = max(ma, i.second);
    }

    cout << n-ma << endl;
}

Measured memory_bytes: 384
w, h, n = map(int, input().split())
wz = 0
hz = 0
w_min = 0
h_min = 0
w_max = w
h_max = h
for i in range (n):
    x, y, a = map(int, input().split())
    if a == 1:
        if x >= w_min:
            wz = x
            w_min = x
    if a == 2:
        if x <= w_max:        
            w = x
            w_max = x
    if a == 3:
        if y >= h_min:
            hz = y
            h_min = y
    if a == 4:
        if y <= h_max:
            h = y
            h_max = y
if w_min < w_max and h_min < h_max:
    print((w-wz)*(h-hz))
else:
    print(0)

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

t_list=[]

for i in range(n):
  f_list = list(map(int, input().split()))
  f_list.pop(0)
  for j in range(len(f_list)):
    t_list.append(f_list[j])

count = 0
for k in range(m):
  if t_list.count(k+1) == n:
    count += 1
print(count)


Measured memory_bytes: 3060
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from heapq import heapify, heappop, heappush
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, M = MAP()
L = [LIST() for i in range(N)]

# L = [-1, 1] #生成する数字
num = 3 #生成するビット数
bit_list = list(product([-1, 1], repeat=num))

# print(bit_list)
ans = 0
for a, b, c in bit_list:
    tmp = [a * x + b * y + c * z for x, y, z in L]
    tmp.sort(reverse=True)
    selected = sum(tmp[0:M])
    if ans < selected:
        ans = selected
    # ans.append(sum(tmp[0:M]))
print(ans)




Measured memory_bytes: 4072
[<AutoOpen>]
module Program

open System

let read f = stdin.ReadLine() |> f
let reada f = stdin.ReadLine().Split() |> Array.map f
let reads f = stdin.ReadLine().Split() |> Array.toList |> List.map f

let upperBound (array: 'T []) first last value =
    let rec loop left right =
        if left > right then
            left
        else
            let mid = left + ((right - left) >>> 1)
            if array.[mid] <= value then
                loop (mid + 1) right
            else
                loop left (mid - 1)
    loop first (last - 1)

[<EntryPoint>]
let main _ =
    let N = read int
    let LS = reada int |> Array.sort

    let mutable ans = 0
    for i in [N-1 .. -1 .. 2] do
        for j in [i-1 .. -1 .. 1] do
            let high = LS.[i]
            let mid = LS.[j]
            let bound = upperBound LS 0 LS.Length (high - mid)
            let lows = max 0 (j - bound)
            ans <- ans + lows

    Console.WriteLine(ans)
    0

Measured memory_bytes: 36356
#include<iostream>

using namespace std;
int main() {
	int a, b,k;
	cin >> a >> b >> k;

	int count = 0;
	int ans;

	for (int i = 100; i >= 1; i--)
	{
		if (a % i == 0 && b % i == 0 && count != k-1)count++;
		else if (a % i == 0 && b % i == 0)
		{
			cout << i << endl;
			return 0;
		}
	}
}

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

using namespace std;

#define INF 1e9

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

    string s;
    cin>>s;

    vector<int> sum(3);

    for(int i=0;i<s.size();i++){
        if(s[i]=='a')sum[0]++;
        else if(s[i]=='b')sum[1]++;
        else sum[2]++;
    }

    sort(sum.begin(),sum.end());

    bool ans=((sum[2]-sum[0])<2);

    if(ans)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;

}

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

int c[15],n;

void dfs(int x)
{
	if(x==n+1) {
		int las=0;
		for(int i=1;i<=n;++i) {
			if(c[i]>las+1) return;
			las=max(las,c[i]);
		}
		for(int i=1;i<=n;++i) putchar('a'+c[i]-1);
		puts("");
		return ;
	}
	for(int i=1;i<=x;++i) {
		c[x]=i;
		dfs(x+1);
	}
}

int main()
{
	scanf("%d",&n);
	dfs(1);
}

Measured memory_bytes: 1536
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		@SuppressWarnings("resource")
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();

		if ((n / 100) == (n % 10)) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

	}

}


Measured memory_bytes: 21716
/*
AizuOnline A0017
Caesar Cipher
*/
#include <stdio.h>
#include <string.h>

unsigned char ango[1000];
unsigned char ango2[1000];
#define AZ_dif ('Z'-'A'+1) 
#define DELIM " .\n"
int diff;
int same_dist(char c1,char c2,char c3,char c4)
{return(((c1-c2)-(c3-c4)) % AZ_dif == 0);
}


main()
{
  int i;
  char *p;

  while (NULL!=gets(ango))
    {
      strcpy(ango2,ango);
      diff=-99;
   
      p=strtok(ango2,DELIM);
      do {
	if(same_dist(p[0],p[1],'t','h') 
	   && ((strlen(p) == 3 && same_dist(p[0],p[2],'t','e')) 
	       || (strlen(p) == 4 && same_dist(p[0],p[2],'t','i')
		   && same_dist(p[0],p[3],'t','s'))
	       || (strlen(p) == 4 && same_dist(p[0],p[2],'t','a')
		   && same_dist(p[0],p[3],'t','t'))))

	  { diff = 't' - p[0];
	    break;
	  }
      }  while(p=strtok(NULL,DELIM));
      
      
      for(i=0;ango[i];i++)
	if(isalpha(ango[i]))
	  {
	    ango[i] += diff;
	    if(ango[i] > 'z')
	      ango[i] -= 26;
	    if(ango[i] < 'a')
	      ango[i] += 26;
	  }
      if(diff != -99)
	{
	  printf("%s\n",ango);
#ifdef DEBUG
	  printf("%d %d %d\n",ango[1],ango[5],ango[7]);
#endif
	    }
    }

return(0);
}

Measured memory_bytes: 520
#include <stdio.h>

int main() {
    int x, y, z, a, b, c;
    scanf("%d%d%d", &x, &y, &z);
    
    b = x;
    a = y;
    c = a;
    a = z;
    
    printf("%d %d %d\n", a, b, c);
    
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
static const int MOD = 1000000000+7;

int main() {
  int n,m;
  cin >> n >> m;
  vector<bool> goodPeaks(n+1,true);
  goodPeaks.at(0) = false;
  vector<int> heights(n+1);
  for (int i=1; i<n+1; i++) {
    cin >> heights.at(i);
  }

  for (int i=0; i<m; i++) {
    int a,b;
    cin >> a >> b;
    if (heights.at(a) > heights.at(b)) goodPeaks.at(b) = false;
    else if (heights.at(a) < heights.at(b)) goodPeaks.at(a) = false;
    else goodPeaks.at(a) = goodPeaks.at(b) = false;
  }

  int ans=0;
  for (int i=1; i<n+1; i++) {
    ans += goodPeaks.at(i);
  }

  cout << ans << endl;
}

Measured memory_bytes: 3784
//Krunal_Mathukiya
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define li long int
#define pb push_back
#define mkp make_pair
#define nikalL return
#define chalavo continue
#define basHo break
#define umap unordered_map
#define fr(i,s,n) for(int i=s;i<=n;++i)
#define frr(i,s,n) for(int i=s;i>=n;--i)
#define jaldiKarNe ios_base::sync_with_stdio(false);cin.tie(NULL);
#define mod 1000000007
// 1-> taro
// 0-> jiro
int n;
int arr[102];
int dp[100005][2];
int vis[100005][2];
int fn(int k,int turn) {
	cout<<k<<" "<<turn<<endl;
	if(k<arr[1]) {
		if(turn) return 0;
		return 1;
	}
	if(vis[k][turn]) return dp[k][turn];
	vis[k][turn]=1;
	if(turn) { //taro
		int win=0;
		int loose=0;
		fr(i,1,n) {
			if(fn(k-arr[i],1-turn)) win++;
			else loose++;
		}
		if(win) return dp[k][turn]=1;
		else return dp[k][turn]=0;
	}
	else { //jiro
		int win=0;
		int loose=0;
		fr(i,1,n) {
			if(fn(k-arr[i],1-turn)) loose++;
			else win++;
		}
		if(win) return dp[k][turn]=0;
		else return dp[k][turn]=1;
	}
}
int main(){
//	jaldiKarNe;
	int K;
	cin>>n>>K;
	fr(i,1,n) cin>>arr[i];
	fr(k,0,K) {
		fr(turn,0,1) {
//			if(arr[1]>k) {
//				if(turn) dp[k][turn]=0;
//				else dp[k][turn]=1;
//				continue;
//			}
			if(turn) { //taro
				int win=0;
				int loose=0;
				fr(i,1,n) {
					if(k<arr[i]) {
						loose++;
						break;
					}
					if(dp[k-arr[i]][1-turn]) win++;
					else loose++;
				}
				if(win) dp[k][turn]=1;
				else dp[k][turn]=0;
			}
			else { //jiro
				int win=0;
				int loose=0;
				fr(i,1,n) {
					if(k<arr[i]) {
						loose++;
						break;
					}
					if(dp[k-arr[i]][1-turn]) loose++;
					else win++;
				}
				if(win) dp[k][turn]=0;
				else dp[k][turn]=1;
			}
		}
	}
	int ans=dp[K][1];
	if(ans) cout<<"First";
	else cout<<"Second";
}


Measured memory_bytes: 4296
X,Y,A,B,C = map(int,input().split())
p = list(map(int,input().split()))
q = list(map(int,input().split()))
r = list(map(int,input().split()))

p.sort(reverse = True)
q.sort(reverse = True)
r.sort(reverse = True)

eat = []

for i in range(X):
    eat.append(p[i])
for i in range(Y):
    eat.append(q[i])

eat.sort()

for i in range(min(X+Y,len(r))):
    if eat[i] < r[i]:
        eat[i] = r[i]
    else:
        break

print(sum(eat))

Measured memory_bytes: 109676
#!/usr/bin/env python3

import re

S = input()
S = re.split("/",S)

if(int(S[0]) <= 2019):
    if(int(S[1]) == 4):
        if(int(S[2]) <= 30):
            print("Heisei")
        else:
            print("TBD")
    elif(int(S[1]) < 4):
        print("Heisei")
    else:
        print("TBD")
else:
    print("TBD")


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

int h, w, k;
int choices(vector<vector<int>>& grid) {
	int total = 0;
	for (int i = 0; i < (1 << h); i++) {
		for (int j = 0; j < (1 << w); j++) {
			int cur = 0;
			for (int r = 0; r < h; r++) {
				for (int c = 0; c < w; c++) {
					if ((i & (1 << r)) && ((j & (1 << c))))
						cur += grid[r][c];
				}
			}
			total += cur == k;
		}
	}
	return total;
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin >> h >> w >> k;
	vector<vector<int>> grid(h, vector<int>(w));
	for (int i = 0; i < h; i++) {
		string s;
		cin >> s;
		for (int j = 0; j < w; j++) {
			grid[i][j] = s[j] == '#';
		}
	}
	cout << choices(grid);
}



Measured memory_bytes: 3640
import sys
input = lambda: sys.stdin.readline().rstrip() 

def resolve():
    K = int(input())
    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]
    print(A[K-1])

if __name__ == '__main__':
    resolve()

Measured memory_bytes: 3060
#include <iostream>
#include <functional>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <queue>
// #include <prettyprint.hpp>
using namespace std;
typedef long long llong;
// static const llong max_n = 200010;
// vector<vector<llong>> dp(max_n, vector<llong>(10, 0));
// static const int max_n = 110;
// static const llong max_cost = 2000000000000000;
// // vector<vector<llong>> matrix(max_n, vector<llong>(max_n, 0));
// // vector<vector<llong>> adj_matrix(max_n, vector<llong>(max_n, max_cost));
// vector<vector<pair<llong, int>>> adj_list(max_n);
// vector<llong> distance_table(max_n, max_cost);
// set<pair<llong, int>> points_sort_x;
// set<pair<llong, int>> points_sort_y;

// int N;
llong N, K, C;
string S;
vector<llong> ok_days_ordered;
vector<llong> ok_days_reverse;

// template<typename T>
// void print_vec(vector<pair<llong, llong> vec){
//     cout << "[";
//     for(int i=0;i<vec.size();i++){
//         cout << vec[i] << " ";
//     }
//     cout << "]\n"
// }


int main(){
    // int u, v;
    // bool updated = false;
    llong no_work_day=0;
    scanf("%lld %lld %lld", &N, &K, &C);
    cin >> S;
    llong i = 0;
    while(i<N && ok_days_ordered.size() < K){
        if(S[i]=='x'){
            i ++;
            continue;
        } 
        if(S[i]=='o'  && no_work_day == 0){
            ok_days_ordered.push_back(i);
            i = i + C + 1;
        }
    }

    // print_vec(ok_days_ordered);
    // cout << ok_days_ordered <<"\n";
    i = N-1;

    while(i>=0 && ok_days_reverse.size() < K){
        if(S[i]=='x'){
            i --;
            continue;
        } 
        if(S[i]=='o'){
            ok_days_reverse.push_back(i);
            i = i - C - 1;
        }
    }
    // cout << ok_days_reverse <<"\n";


    llong j = 0;
    vector<llong> ans;
    for(i=K-1;i>=0;i--){
        j = K - 1 - i;
        // cout << "ordered i = " << i << " " << ok_days_ordered[i] << "\n";
        // cout << "ordered j = " << j << " " << ok_days_reverse[j] << "\n";
        if(ok_days_ordered[i] == ok_days_reverse[j]){
            ans.push_back(ok_days_ordered[i]);
        }

    }

    if(ans.size()>0){
        for(int k=ans.size()-1;k>=0;k--){
            printf("%lld\n", ans[k]+1);
        }
    }else{
        printf("\n");
    }

        



    // double limit = 1. / (double)(4 * M);



    return 0;

}

Measured memory_bytes: 6644
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

//C++14 (GCC 5.4.1)
int main() {
    int N,W;
    cin >>N >>W;

    vector<int> w(N),v(N);
    rep(i,N) cin >> w.at(i) >>v.at(i);
    
    //-----------------------------------
    int Ans=0;
    vector<vector<long long>> dp(N+1,vector<long long>(W+1,0));
    //i番目までの品物から重さがsumw以下になるように選んだときの価値の総和の最大値
    rep(i,N){
        rep(sumw,W+1){//こっちには+1が必要（先を見たループじゃないので）
            if(sumw >= w.at(i)){//i番目の商品を選ぶ場合
                chmax(dp.at(i+1).at(sumw),dp.at(i).at(sumw-w.at(i))+v.at(i));
            }
            //選ばない場合
            chmax(dp.at(i+1).at(sumw),dp.at(i).at(sumw));
        }
    }

    cout << dp.at(N).at(W) <<endl;
}

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

using namespace std;

const int N = int(1e6);
int a[N];

int main(){
	int n;

	scanf("%d", &n);

	int mx = 0;
	int mx1 = 0;

	for(int i = 0 ; i < n ; i++){
		scanf("%d", &a[i]);

		if(a[i] >= mx){
			mx1 = mx;
			mx = a[i];
		}else{
			mx1 = max(mx1, a[i]);
		}
	}

	int cnt = 0;

	for(int i = 0 ; i < n ; i++){
		if(a[i] == mx){
			cnt++;
		}
	}

	if(cnt > 1){
		for(int i = 0 ;i < n ; i++){
			printf("%d\n", mx);
		}
	}else{
		for(int i = 0 ; i < n ; i++){
			if(a[i] == mx){
				printf("%d\n", mx1);
			}else{
				printf("%d\n", mx);
			}
		}
	}

	return 0;
}

Measured memory_bytes: 2432
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);i++)
#define int long long  
signed main(){
    int N,A,B;
    string S;
    cin >> N >> A >> B;
    cin >> S;
    int a=0,b=0;
    REP(i,S.size()){
        if(S[i]=='a'){
            if(a+b<A+B){
                cout << "Yes" << endl;
                a++;
            }else{
                cout << "No" << endl;
            }
        }else if(S[i]=='b'){
            if(a+b<A+B && b<B){
                cout << "Yes" << endl;
                b++;
            }else{
                cout << "No" << endl;
            }
        }else{
            cout << "No" << endl;
        }
    }
	return 0;
}


Measured memory_bytes: 896
#include <iostream>

int main() {

  int A;
  int B;
  int X;

  std::cin >> A >> B >> X;

  if (A<=X && B>=X-A) {
    std::cout << "YES" << std::endl;
  } else {
    std::cout << "NO" << std::endl;
  }

  return 0;
}

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

int main() {
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());

    int n, k, x, y;
    cin >> n >> k >> x >> y;

    // k泊まではx円, k+1泊目以降はy円
    if (n - k < 0) {
        cout << x * n << endl;
    } else {
        cout << x * k + y * (n - k) << endl;
    }
    
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES // for C++  
#include "bits/stdc++.h"
using LL = long long;
using ULL = unsigned long long;
#define NUM 1000000007

using namespace std;

int main()
{
    int a, b;
    cin >> a >> b;
    if ((a*b)%2==0)
    {
        cout << "Even" << endl;
    }
    else
    {
        cout << "Odd" << endl;
    }
}

Measured memory_bytes: 256
n, A, B = map(int, input().split())

s = input()

pas = 0
overseas = 1

for i in range(n):
    if s[i] == 'a':
        if pas < A + B:
            print("Yes")
            pas += 1
        else:
            print("No")
    elif s[i] == 'b':
        if pas < A + B and overseas <= B:
            print("Yes")
            pas += 1
            overseas += 1
        else:
            print("No")
    else:
        print("No")
        

Measured memory_bytes: 9304
#include<iostream>
using namespace std;
 
int main()
{
  int H1, M1, H2, M2, K, H;
  cin >> H1 >> M1 >> H2 >> M2 >> K;
  
  H = (H2 - H1) * 60;
  if(M2 >= M1)
  {
    cout << H + (M2 - M1) - K << endl;
  }
  else
  {
    cout << H - (M1 - M2) - K << endl;
  }
  
  return 0;
}

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

int main() {
  
  vector<int> t(3);
  
  rep(i,3) cin >> t[i];
  
  sort(t.begin(), t.end());
  
  cout << t[0]+t[1] << endl;
  
}


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

void winter_is_coming()
{
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL); cout.tie(NULL );
}

int main()
{
   winter_is_coming();

    int a,b,c,t;
    cin>>a>>b>>c;
   if(a==0 && b==0) cout<<0<<"\n";
   else if(a+b>=c-1) cout<<c+b<<"\n";
   else
   {
       cout<<a+b+1+b<<"\n";
   }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <string>
#include <cmath>
#include <complex>
#include <map>
using namespace std;

#define rep(i,n) for(int i=0;i<int(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define EPS 1e-8

static const double PI=6*asin(0.5);
typedef complex<double> P;
typedef long long ll;

int cou=0;
int x,y;
char t;
ll msum=0,nsum=0;


int main(){
	while(cin>>x>>t>>y){
		msum+=x*y;
		nsum+=y;
		cou++;
	}
	double res=(double)(nsum)/(double)(cou);
	//cout<<res<<endl;
	cout<<msum<<endl;
	cout<<(int)(res+0.5)<<endl;
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <cstring>
#include <cmath>

using namespace std;

int main() {
  string s;

  cin >> s;

  int n = s.length();

  if(n == 2) {
    if(s[0] == s[1]) {
      cout <<"NO" << endl;
      return 0;
    }
  }
    if(n == 3) {
      if(s[0] == s[1] || s[0] == s[2] || s[1] == s[2]) {
	cout << "NO" << endl;
	return 0;
      }
    }
    int c[3] = {};

      for(int i = 0; i < n; i++) {
	c[s[i] - 'a']++;
      }

      int tmp = abs(c[0] - c[1]);
      int tmp2 = abs(c[1] - c[2]);
      int tmp3 = abs(c[2] - c[0]);
      
      if(tmp > 1 || tmp2 > 1 || tmp3 > 1) {
	cout << "NO" << endl;
	return 0;
      }

      cout << "YES" << endl;
}


Measured memory_bytes: 512
#include <algorithm>
#include <iostream>
#include <string>

using namespace std;

int main(void){
	string s;
	cin >> s;
	reverse(s.begin(),s.end());
	int flag=1;
	while(!s.empty()){
		if(s.find("remaerd")==0){
			s.erase(0,7);
		}else if(s.find("resare")==0){
			s.erase(0,6);
		}else if(s.find("esare")==0||s.find("maerd")==0){
			s.erase(0,5);
		}else{
			flag=0;
			break;
		}
	}
	if(flag){
		cout << "YES" << endl;
	}else{
		cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 512
#include<cstdio>
#include<algorithm>
#include<cmath>
using namespace std;
int n, C[15];
double w[15][15], MM[32768], D[32768];
struct point{
    int x,y;
}P[15];
double Prim(int mask){
    int i, j;
    double DP[15], res = 0.0;
    bool v[15];
    for(i=0;i<n;i++)DP[i]=1e18,v[i]=false;
    for(i=0;i<n;i++)if((1<<i)&mask)break;
    DP[i]=0.0;
    while(1){
        double Mn = 1e18;
        int pv = -1;
        for(j=0;j<n;j++){
            if(!((1<<j)&mask))continue;
            if(Mn>DP[j] && !v[j])Mn=DP[j],pv=j;
        }
        if(pv==-1)break;
        res += DP[pv];
        v[pv] = true;
        for(j=0;j<n;j++)DP[j] = min(DP[j],w[pv][j]);
    }
    return res;
}
void DFS(int m1, int m2, int cur, int pv){
    if(pv==n){
        D[m1|cur] = max(D[m1|cur], min(D[m1],MM[cur]));
        return;
    }
    if((1<<pv)&m2) DFS(m1, m2, cur|(1<<pv), pv+1);
    DFS(m1, m2, cur, pv+1);
}
int main(){
    int i, j;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d%d%d",&P[i].x,&P[i].y,&C[i]);
    }
    for(i=0;i<n;i++)for(j=0;j<n;j++)w[i][j]=sqrt(1.0*(P[i].x-P[j].x)*(P[i].x-P[j].x)+1.0*(P[i].y-P[j].y)*(P[i].y-P[j].y));
    for(i=1;i<(1<<n);i++){
        double e = -Prim(i);
        int c = 0;
        for(j=0;j<n;j++)if(i&(1<<j))e +=C[j], c++;
        MM[i] = e/c;
    }
    D[0] = 1e18;
    for(i=0;i<(1<<n);i++){
        DFS(i, (1<<n)-1-i, 0, 0);
    }
    printf("%.11f\n",D[(1<<n)-1]);
}

Measured memory_bytes: 640
void main(){
	long n, m, k;
	readf("%d %d %d\n", &n, &m, &k);
	// 読み込み
	long[] in_a = _scanln!long();
	long[] in_b = _scanln!long();
	// 配列をそれまでの累積値として再計算
	long[] a = [0];
	long[] b = [0];
	foreach(i; 0..n) a ~= a[i] + in_a[i];
	foreach(i; 0..m) b ~= b[i] + in_b[i];

	// aから徐々に選択していく
	long ans;
	long j = m; // aが選択されるごとに選択できるbの個数jは減る
	foreach(i, alm; a){
		if(alm > k)break; // 時間超過
		// bの選択
		while(b[j] > k-a[i])j--;
		ans = max(ans, i+j); 
	}
	ans.writeln();
}

import std.stdio, std.conv, std.algorithm, std.numeric, std.string, std.math, std.range, std.container;

// 1要素のみの入力
T _scan(T= int)(){
	return to!(T)( readln().chomp() );
}

// 1行に同一型の複数入力
T[] _scanln(T = int)(){
	T[] ln;
	foreach(string elm; readln().chomp().split()){
		ln ~= elm.to!T();
	}
	return ln;
}


Measured memory_bytes: 24400
#include<bits/stdc++.h>
#define rep(i,n) for(int (i) = 0;(i) < (n);(i)++)
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
// cd test ; rm -R ./*; cd ..


int main(void) {
  string s;cin >> s;
  string ans;
  if (s == "SAT") cout << 1;
  if (s == "FRI") cout << 2;
  if (s == "THU") cout << 3;
  if (s == "WED") cout << 4;
  if (s == "TUE") cout << 5;
  if (s == "MON") cout << 6;
  if (s == "SUN") cout << 7;
  
  return 0;
}


Measured memory_bytes: 256
// A - Biscuits: https://beta.atcoder.jp/contests/agc017/tasks/agc017_a
// P=0とP=1で場合分け。P=0の場合、奇数個のビスケット袋から偶数個、P-1の場合奇数個のビスケット袋から奇数個とる。
// N>=50なのでintではだめ。

#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
  
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
  
using namespace std;
  
typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
  
const int INF=1<<29;
const double EPS=1e-9;
  
const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};
 
long long dp[51][51];
 
long long comb(int n, int r) {
    if (dp[n][r] != -1) return dp[n][r];
    if (r == 0) return dp[n][r] = 1;
    if (n == r) return dp[n][r] = 1;
    return dp[n][r] = comb(n - 1, r - 1) + comb(n - 1, r);
}
 
int main() {
 
    for (int i = 0; i < 51; i++) {
        for (int j = 0; j < 51; j++) {
            dp[i][j] = -1;
        }
    }
 
    int N, P;
    cin >> N >> P;
    vector<int> A(N);
    int sum = 0;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        A[i] %= 2;
        sum += A[i];
    }
    int rest = N - sum;
    long long ret = 0;
    if (P == 0) {
        for(int i = 0; i <= sum; i+=2) {
            ret += comb(sum, i) * (1LL << rest);
        }
    } else {
        for(int i = 1; i <= sum; i+=2) {
            ret += comb(sum, i) * (1LL << rest);
        }
    }
    cout << ret << endl;
 
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int m = sc.nextInt();
        int d = sc.nextInt();
        int count = 0;
        for (int i = 1 ; i <= m ;i++) {
            for (int j = 10 ; j <= d ; j++) {
                int d1 = j % 10;
                int d2 = j / 10;
                if (d1 >= 2 && d2 >= 2 && d1 * d2 == i) {
                    count++;
                }
            }
        }

        System.out.println(count);

    }

}

Measured memory_bytes: 22868
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<climits>
#include<set>
#include<tuple>
#include<stack>


using namespace std;

int main() {

	int G, R;
	cin >> R >> G;
	int x;
	x = 2 * G - R;
	cout << x << endl;

	return 0;
}


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

using namespace std;

int main() {

    int N; cin >> N;
    string st; cin >> st;

    vector<int> s(N);
    if (st[0] == 'W') s[0] = 1;
    else s[0] = 0;
    for (int i = 1; i < N; i++) {
        s[i] = s[i-1];
        if (st[i] == 'W') s[i]++;
//        cout << i << ": " << s[i] << endl;
    }

    int ans = (1<<21);
    for (int i = 0; i < N; i++) {
        
        if (i == 0) {
            ans = min(ans, (N-1-s[N-1]+s[0]) );
//            cout << 0 << " " << N-1-s[N-1]+s[0] << endl;
        } else if ( i == N-1 ) {
//            cout << N-1 << " " << s[N-2] << endl;
            ans = min(ans, s[N-2]);
        } else {
//            cout << s[i-1] << " " << N-i-1-s[N-1]+s[i] << endl;
            ans = min(ans, s[i-1] + (N-i-1 - s[N-1] + s[i]));
        }
    }

    cout << ans << endl;

    return 0;
}


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

#define for_(i,a,b) for(int i=a;i<b;++i)
#define ALL(a) a.begin(),a.end()
#define INIT(a,b) memset(a,b,sizeof(a))
using lint = long long int;

int main() {
    int N;
    lint K;
    cin >> N >> K;

    vector<int> A(N);
    for_(i,0,N) cin >> A[i];

    auto valid = [&](int x) {
        lint cnt = 0;
        for_(i,0,N) cnt += ((A[i] + x - 1) / x) - 1;
        return cnt <= K;
    };

    int lb = 0, ub = 1L << 30;
    while (ub - lb > 1) {
        int med = (ub + lb) / 2;
        if (valid(med)) ub = med;
        else lb = med;
    }
    cout << ub << endl;
}

Measured memory_bytes: 4036
n = int(input())

def dfs(s, mx):
    if len(s) == n:
        print(s)
    else:
        for i in range(ord("a"), ord(mx) + 2):
            tmp = s
            tmp += chr(i)
            dfs(tmp, max(mx, chr(i)))

dfs("a", "a")

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

int main(void){
  string A, B;
  string decision;
  cin >> A >> B;
  if(A.size() > B.size()){
    decision = "GREATER";
  }
  else if(A.size() < B.size()){
    decision = "LESS";
  }
  else{
    for(int i=0;i<A.size();++i){
      if(A[i] == B[i]){
        if(i == A.size()-1){
          decision = "EQUAL";
        }
        continue;
      }
      else if(A[i] > B[i]){
        decision = "GREATER";
        break;
      }
      else{
        decision = "LESS";
        break;
      }
    }
  }
  cout << decision << endl;
}


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

#define mod 1000000007

int main(){
    int n,m;
    cin >> n >> m;
    if (m>n) swap(n,m);
    long long ans=0;
    if (n-m<=1){
        long long N=1,M=1;
        for (long long i=1;i<=(long long)n;i++){
            N*=i;
            N%=mod;
        }
        for (long long i=1;i<=(long long)m;i++){
            M*=i;
            M%=mod;
        }
        ans=(N*M)%mod;
        if (n-m==1) cout << ans;
        else cout << (ans*2)%mod;
        //cout << endl << ans << ' ' << (ans*2)%mod;
    } else cout << "0";
}


Measured memory_bytes: 256
#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<cstdio>
#include<vector>
#include<cctype>
#include<cstdlib>
#include<cstring>
#include<utility>
#include<algorithm>

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define For(i,x,y) for(int i=((int)x);i<=((int)y);i++)
#define Dep(i,y,x) for(int i=((int)y);i>=((int)x);i--)
#define Rep(i,x) for (int y,i=head[x];i;i=E[i].nxt)
using namespace std;

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

int rd() {
	char c=getchar(); int t=0,f=1;
	while (!isdigit(c)) f=(c=='-')?-1:1,c=getchar();
	while (isdigit(c)) t=t*10+c-48,c=getchar(); return t*f;
}
void wt(int x) {
	if (x<0) putchar('-'),wt(-x);
	else { if (x>9) wt(x/10); putchar(x%10+48); }
}

ll n,m,ans=1e18,x,y,z,l;

ll Abs(ll x) {
	if (x>0) return x; else return -x;
}

void solve() {
	For (i,1,n-1) {
		x=1ll*i*m;
		if ((n-i)%2==0) y=(n*m-x)/2,ans=min(ans,Abs(x-y));
		else {
			if (m%2==0) y=(n*m-x)/2,ans=min(ans,Abs(x-y));
			else {
				l=m/2;
				y=1ll*l*(n-i);
				z=1ll*m*(n-i)-y;
				ll p=max(x,max(y,z)),q=min(x,min(y,z));
				ans=min(ans,p-q);
				
				l=(n-i)/2;
				y=1ll*l*m;
				z=1ll*(n-i)*m-y;
				p=max(x,max(y,z)),q=min(x,min(y,z));
				ans=min(ans,p-q);
			}
		}
	}
}

int main() {
	n=rd(),m=rd();
	solve();
	swap(n,m);
	solve();
	printf("%lld\n",ans);
	return 0;
}






Measured memory_bytes: 128
#include <cstdio>
#include<algorithm>
#define mod 1000000007

using namespace std;
typedef long long ll;
const int maxn = 50+10;

int a[maxn];

int main() {
	int n,k,sum=0;
	scanf("%d %d",&n,&k);
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
	}
	sort(a+1,a+1+n);
	
	for(int i=n;i>n-k;i--){
		sum+=a[i];
	}
	printf("%d\n",sum);
	return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> vec(N);
  rep(i, N) cin >> vec[i];
  vector<int> vec_s = vec;
  sort(vec_s.begin(),vec_s.end());
  if (vec == vec_s)
    cout << "YES" << endl;
  else {
    int sum = 0;
    rep(i, N) {
      if (vec[i] != vec_s[i]) sum++;
    }
    if (sum != 2)  cout << "NO" << endl;
    else  cout << "YES" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int N;cin >> N;
  int n = (N-1)/2;
  cout << n << endl;
  return 0;
}


Measured memory_bytes: 256
from math import sqrt
N = int(input())
d = []
ans = 10 ** 12 + 1
for i in range(1,int(sqrt(N)+1)):
    if N % i == 0:
        d.append((i, int(N / i)))
for i in d:
    x, y = i
    cnt = x - 1 + y - 1
    ans = min(ans, cnt)
print(ans)

Measured memory_bytes: 3444
#include <algorithm>
#include <iostream>
#include <limits.h>
#include <stdlib.h>
#include <string>
#include <vector>

#define el endl
#define fd fixed
#define INF INT_MAX/2-1

using namespace std;

int main() {
  string s, right = "yuiopjhklnm";
  int count;
  bool use_right;
  while (cin >> s, s != "#") {
    count = 0;
    if ((int)right.find(s[0]) >= 0) use_right = true;
    else use_right = false;
    for (int i = 1; i < s.length(); i++) {
      if (use_right && (int)right.find(s[i]) < 0) {
        use_right = false;
        count++;
      }
      else if (!use_right && (int)right.find(s[i]) >= 0) {
        use_right = true;
        count++;
      }
    }
    cout << count << el;
  }
}

Measured memory_bytes: 1188
#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 ll long long
#define X first
#define Y second
#define all(x) x.begin(), x.end()
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
	enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
	ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
	*this << "[";
	for (auto it = d.b; it != d.e; ++it)
		*this << ", " + 2 * (it == d.b) << *it;
	ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

const int mod = (int)1e9 + 7;
const int MX = (int)1e5 + 10;

void add_self(int &x, int y){x += y; if(x >= mod) x -= mod;}
void sub_self(int &x, int y){x -= y; if(x < 0) x += mod;}
void mul(int &x, int y){x = x * 1LL * y % mod;}

int main(){

	cin.tie(0); cout.tie(0);
	ios_base::sync_with_stdio(0);

	int w, s;
	cin >> s >> w;
	if(w >= s) puts("unsafe");
	else puts("safe");

	return 0;
}

Measured memory_bytes: 3656
#　各桁の和を計算する
def findSumOfDigits(n):
    sum_digits = 0
    while n > 0 :
        sum_digits += n % 10
        n //= 10
    return sum_digits


def main()->None:
    N = int(input())
    # AとBの各桁の和を求める。
    range_A = range(1,N+1)
    min_total = 100000
    for a in range_A:
        b = N - a
        if b < 1 : continue
        sum_a = findSumOfDigits(a)
        sum_b = findSumOfDigits(b)
        total = sum_a + sum_b
        if total < min_total:
            min_total = total
    print(min_total)


if __name__ == "__main__":
    main()

Measured memory_bytes: 3064