akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

int main(){
  int size,i;
  int key[251];

  scanf("%d",&size);
  for(i=1;i<=size;i++){
    scanf("%d",&key[i]);
  }

  for(i=1;i<=size;i++){
    printf("node %d: ",i);
    printf("key = %d, ",key[i]);
    if(1<=i/2 && i/2<=size) printf("parent key = %d, ",key[i/2]);
    if(1<=2*i && 2*i<=size) printf("left key = %d, ",key[2*i]);
    if(1<=2*i+1 && 2*i+1<=size) printf("right key = %d, ",key[2*i+1]);
    printf("\n");
  }

  return 0;
}
			



Measured memory_bytes: 2108
import java.util.*;

public class Main {
  public static void main(String[] args) {
    @SuppressWarnings("resource")
    Scanner sc = new Scanner(System.in);
    int X = sc.nextInt();
    int t = sc.nextInt();
    int ans = (X - t) >= 0 ? (X - t) : 0;

    System.out.println(ans);
  }
}


Measured memory_bytes: 21716
def main():
  N, M = map(int, input().split())
  A_list = list(map(int, input().split()))

  req_days = sum(A_list)

  ans = N-req_days

  if ans >= 0:
    print(ans)
  else:
    print(-1)


if __name__ == "__main__":
  main()

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

#define LL long long
#define VI vector<int>
#define VVI vector<vector<int>>
#define VVVI vector<vector<vector<int>>>
#define VL vector<LL>
#define VVL vector<vector<LL>>
#define VVVL vector<vector<vector<LL>>>
#define VB vector<bool>
#define FOR(i,a,b) for(int i= (a); i<((int)b); ++i)
#define RFOR(i,a) for(int i=(a); i >= 0; --i)
#define FOE(i,a) for(auto i : a)
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v,x) (std::find(v.begin(), v.end(), x) != v.end())
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define EPS 1e-14

template<class T> T ceil(T a, T b) { return (a + b - 1) / b; }
template<class T> void print(T x) { std::cout << x << std::endl; }

const std::string YES = "YES", Yes = "Yes", NO = "NO", No = "No";
const std::vector<int> dy = { 0, -1, 0, 1 }, dx = { 1, 0, -1, 0 };    // 4近傍（右, 下, 左, 上）

using namespace std;

class CumulativeSum {

public:
    vector<int> memo1;
    vector<vector<int>> memo2;

    // boardの累積和を作成
    CumulativeSum(const vector<vector<int>> &board) {
        int height = board.size();
        int width = board[0].size();
        this->memo2 = vector<vector<int>>(height + 1, vector<int>(width + 1, 0));

        for (int y = 0; y < height; ++y) {
            for (int x = 0; x < width; ++x) {
                memo2[y + 1][x + 1] = board[y][x] + memo2[y + 1][x];
            }
            for (int x = 0; x < width; ++x) {
                memo2[y + 1][x + 1] += memo2[y][x + 1];
            }
        }
    }

    /*
    (y1, x1)から(y2, x2)の合計を返す．(y2, x2)は含まない
    座標はmemoを作成したboard準拠
    (ex, sum(0, 0, 2, 2)なら(0, 0), (0, 1), (1, 0), (1, 1)の合計を返す)
    */
    int sum(int y1, int x1, int y2, int x2) {
        return this->memo2[y2][x2] - this->memo2[y2][x1] - this->memo2[y1][x2] + this->memo2[y1][x1];
    }

};

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

    int M, N, K;
    cin >> M >> N;
    cin >> K;
    vector<vector<int>> jungle(M, vector<int>(N)), ocean(M, vector<int>(N)), ice(M, vector<int>(N));

    FOR(i, 0, M) {
        FOR(j, 0, N) {
            char c;
            cin >> c;
            if (c == 'J') {
                jungle[i][j] = 1;
            }
            if (c == 'O') {
                ocean[i][j] = 1;
            }
            if (c == 'I') {
                ice[i][j] = 1;
            }
        }
    }

    CumulativeSum cs_j(jungle), cs_o(ocean), cs_i(ice);

    FOR(i, 0, K) {
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        cout << cs_j.sum(a - 1, b - 1, c, d) << " " << cs_o.sum(a - 1, b - 1, c, d) << " " << cs_i.sum(a - 1, b - 1, c, d) << endl;
    }

    return 0;
}


Measured memory_bytes: 26148
#include <stdlib.h>
#include <stdio.h>
int compare(const void *a,const void *b){
    return *(int*)b-*(int*)a;
}
int main()
{
    int i,k,n,a[200001]={0},tmp;
    long ans=0;
    scanf("%d%d",&n,&k);
    for(i=0;i<n;i++){
        scanf("%d",&tmp);
        a[tmp]++;
    }
    qsort(a,200001,sizeof(int),compare);
    for(i=k;i<200001;i++){
        ans+=a[i];
    }
    printf("%ld",ans);
    return 0;
}


Measured memory_bytes: 1660
#include <iostream>  
    #include <cstdio> 
    #define ll long long
    using namespace std;  
    int a[100005];  
    int main() {  
        int k;  
        scanf("%d",&k);  
        for (int i=1; i<=k; i++) {  
            scanf("%d",&a[i]);  
        }  
        ll mmax=2,mmin=2;  
        for(int i=k;i>=1&&mmax>=mmin;i--)  
        {  
            if(mmin%a[i]!=0)  
                mmin=mmin/a[i]*a[i]+a[i];  
            mmax=(mmax/a[i]+1)*a[i]-1;  
        }  
        if(mmax>=mmin)  
            printf("%lld %lld\n",mmin,mmax);  
        else  
            printf("-1\n");  
        return 0;  
    }  

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
	    Scanner std = new Scanner(System.in);
	    int w = Integer.parseInt(std.next());
	    int h = Integer.parseInt(std.next());
	    int x = Integer.parseInt(std.next());
	    int y = Integer.parseInt(std.next());
	    int r = Integer.parseInt(std.next());
	    boolean ret = 0<=x-r && x+r<=w && 0<=y-r && y+r<=h;
	    if(ret){
	    	System.out.println("Yes");
	    }else{
	    	System.out.println("No");
	    }

	}
}

Measured memory_bytes: 26224
#include<stdio.h>

bool isEven(int a) {
	return a % 2 == 0 ? true : false;
}

int main(void) {
	int A, B;
	scanf("%d %d", &A, &B);
	bool judge = isEven(A * B);
	if (judge == false) {
		printf("Yes");
	} else {
		printf("No");
	}

	return 0;
}


Measured memory_bytes: 128
n, T = map(int, input().split())
TLE = 0
Min = 100000
for i in range(n):
    c, t = map(int, input().split())
    if t <= T:
        Min = min(Min, c)
        TLE += 1
if TLE==0:
    print("TLE")
else:
    print(Min)

Measured memory_bytes: 38256
# cook your dish here
def gcd(a, b):
	while b:
		a, b = b, a % b
	return a
def lcm(a, b):
	return a * b // gcd (a, b)


n,m = map(int,input().split())
s=list(input())
t=list(input())

g = gcd(n,m)
l = lcm(n,m)

jkl = (n-1)//(n//g)+1
nn = n//g
mm = m//g

c = 0
for i in range(jkl):

    if s[i*nn]==t[i*mm]:
        c += 1
    
if c == jkl:
    print(l)
else:
    print(-1)
    

Measured memory_bytes: 4552
#include <bits/stdc++.h>
using namespace std;
void init () { ios::sync_with_stdio(0); cin.tie(nullptr); }
void chmax (int &a, int b) { if (a < b) { a = b; } }
void chmin (int &a, int b) { if (a > b) { a = b; } }

constexpr int INF = 1e9;

int main() {
    int n;
    cin >> n;
    vector<long long> a(n), b(n), c(n);
    for (auto &e : a) cin >> e;
    for (auto &e : b) cin >> e;
    for (int i = 0; i < n; i++) c[i] = a[i] - b[i];
    
    int ans = 0;
    long long loss = 0;
    for (const auto &e : c) loss += max(0LL, -e);
    sort(c.rbegin(), c.rend());
    for (int i = 0; i < n; i++) {
        if (c[i] < 0) { ans++; continue; }
        if (c[i] == 0) continue;
        if (loss > 0) { loss -= c[i]; ans++; }
    }
    cout << (loss > 0 ? -1 : ans) << endl;
    return 0;
}

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

#define REP(i, n) for(int i = 0;i < n;i++)
#define ll long long

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n, a, b;
	cin >> n >> a >> b;
	vector<int> xi(n);
	REP(i, n){ cin >> xi[i]; }
	ll ans = 0;
	REP(i, n-1){
		ans += min((xi[i+1]-xi[i])*a, b);
	}
	cout << ans << endl;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int n,k;
int main(){
	
	cin>>n>>k;
	int h[n];
	for(int i=0;i<n;i++)
		cin>>h[i];
	vector<int> dp(n,INT_MAX);
    dp[0] = 0;
    for(int i=1;i<n;i++){
        for(int j=1;j<k+1;j++){
            if(0<=(i-j)){
                dp[i] = min(dp[i],dp[i-j]+abs(h[i]-h[i-j]));
            }
        }
    }
    cout<<(dp[n-1])<<endl;
		
}


Measured memory_bytes: 1024
from collections import defaultdict
N, M = map(int, input().split())
PY = [list(map(int, input().split())) for _ in range(M)]

PY_list = defaultdict(list)
for i in range(len(PY)):
    PY_list[PY[i][0]].append([i, PY[i][1]])
#print(PY_list)

py_opt = dict()
for pyl in PY_list.values():
    pyl.sort(key = lambda x: x[1])
    for i in range(len(pyl)):
        #print(i)
        py_opt[pyl[i][0]] = i

#print(py_opt)
#print(PY_list)
for i in range(len(PY)):
    #n = PY_list[PY[i][0]].index([i, PY[i][1]])
    n = py_opt[i]
    print("{:06d}{:06d}".format(PY[i][0], n + 1))

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


i64 n, m, a[101010];
P p[101010];

int main(){
	cin >> n >> m;
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	for(int i = 0; i < m; i++){
		cin >> p[i].second >> p[i].first;
	}
	sort(p, p+m);
	sort(a, a+n);
	
	i64 ans = 0;
	int checked = 0;
	for(int i = m-1; i >= 0; i--){
		if(checked+p[i].second > n){
			for(; checked < n; checked++){
				if(a[checked] >= p[i].first){
					break;
				}
				ans += p[i].first;
			}
			break;
		}
		if(p[i].first < a[checked + p[i].second-1]){
			while(a[checked] < p[i].first){
				ans += p[i].first;
				checked++;
			}
			break;
		}
		ans += p[i].first * p[i].second;
		checked += p[i].second;
	}
	
	for(int i = checked; i < n; i++){
		ans += a[i];
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 2560
#include <iostream>
using namespace std;
int main()
{
  int a,b;
  cin>>a>>b;
  if(a<=13&&a>1&&b<=13&&b>1){
    if(a>b){
        cout<<"Alice";
    }
    else if(b>a){
        cout<<"Bob";
    }
    else if(a==b){
    cout<<"Draw";
  }

  }

  else if(a==1&&b==1){
    cout<<"Draw";
  }
  else if(a==1&&b!=1){
    cout<<"Alice";
  }
  else if(b==1&&a!=1){
    cout<<"Bob";
  }

        return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
int isprime(int x);
int main(){
  int *A,i,N,n,count=0;
  scanf("%d\n",&N);
  A=(int *)malloc(N*sizeof(int));
  for(i=0;i<N;i++){
    scanf("%d",&A[i]);
  }
  for(i=0;i<N;i++){
    n=isprime(A[i]);
    if(n==1) count++;
  }
  printf("%d\n",count);
  return 0;
}
int isprime(int x){
  int i;
  if(x==2) return 1;
  if(x<2||x%2==0) return 0;
  i=3;
  while(i<=sqrt(x)){
    if(x%i==0) return 0;
    i=i+2;
  }
  return 1;
}



Measured memory_bytes: 2108
A, B, C, K = map(int, input().split())
Ts = 0
sA = K - A
if sA > 0:
    sB = sA - B
    if sB > 0:
        sC = sB - C
        if sC < 0:
            Ts = ((K - sA) * 1) + ((sA - sB) * 0) + (sB * -1)
        elif sC == 0:
            Ts = ((K - sA) * 1) + ((sA - sB) * 0) + (sB * -1)
    elif sB == 0:
        Ts = ((K - sA) * 1) + (sB * 0)
    else:
        Ts = ((K - sA) * 1) + ((sA - sB) * 0)
elif sA == 0:
    Ts = A * 1
else:
    Ts = K * 1
print(Ts)

Measured memory_bytes: 9060
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < int(n); i++)
using namespace std;
using ll = long long;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using P = pair<int, int>;
using T = tuple<P, int, int, int>;

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int h, w, k, x1, y1, x2, y2;
  cin >> h >> w >> k >> x1 >> y1 >> x2 >> y2;
  --x1, --y1, --x2, --y2;
  vector<string> s(h);
  rep(i, h) cin >> s[i];
  vector<vector<vector<P>>> grid(h, vector<vector<P>>(w, vector<P>(4, {INF, INF})));
  rep(i, 4) grid[x1][y1][i] = {1, 0};
  priority_queue<T, vector<T>, greater<T>> que;
  rep(i, 4) que.emplace(make_pair(1, 0), x1, y1, i);
  while (!que.empty()) {
    P dist;
    int x, y, d;
    tie(dist, x, y, d) = que.top();
    que.pop();
    if (dist > grid[x][y][d])
      continue;
    rep(i, 4) {
      if (chmin(grid[x][y][i], make_pair(dist.first+1, 0)))
        que.emplace(make_pair(dist.first+1, 0), x, y, i);
    }
    if (x+dx[d] < 0 || x+dx[d] >= h || y+dy[d] < 0 || y+dy[d] >= w)
      continue;
    if (s[x+dx[d]][y+dy[d]] == '@')
      continue;
    if (make_pair(dist.first, dist.second+1) < grid[x+dx[d]][y+dy[d]][d]) {
      if (dist.second < k) {
        grid[x+dx[d]][y+dy[d]][d] = make_pair(dist.first, dist.second+1);
        que.emplace(make_pair(dist.first, dist.second+1), x+dx[d], y+dy[d], d);
      } else {
        grid[x+dx[d]][y+dy[d]][d] = make_pair(dist.first+1, 1);
        que.emplace(make_pair(dist.first+1, 1), x+dx[d], y+dy[d], d);
      }
    }
  }
  int ans = INF;
  rep(i, 4) chmin(ans, grid[x2][y2][i].first);
  if (ans == INF)
    cout << -1 << endl;
  else
    cout << ans << endl;
  return 0;
}

Measured memory_bytes: 144976
//たぶんO(NlogN)の構文解析
#include <iostream>
#include <string>
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;

int NOT[3] = {2, 1, 0};
int AND[3][3] = {{0, 0, 0}, {0, 1, 1}, {0, 1, 2}};
int OR[3][3] = {{0, 1, 2}, {1, 1, 2}, {2, 2, 2}};
string s;
int P, Q, R;

int dfs(int l, int r) {
	if (s[l] == '0') return 0;
	if (s[l] == '1') return 1;
	if (s[l] == '2') return 2;
	if (s[l] == 'P') return P;
	if (s[l] == 'Q') return Q;
	if (s[l] == 'R') return R;
	if (s[l] == '-') return NOT[dfs(l + 1, r)];
	
	int lc = l, cntl = 0;
	int rc = r - 1, cntr = 0;
	int it = -1;
	while (lc <= rc) {
		if (s[lc] == '(') cntl++;
		if (s[lc] == ')') cntl--;
		if (s[lc] == '+' && cntl == 1) { it = lc; break; }
		if (s[lc] == '*' && cntl == 1) { it = lc; break; }
		lc++;
		
		if (s[rc] == '(') cntr--;
		if (s[rc] == ')') cntr++;
		if (s[rc] == '+' && cntr == 1) { it = rc; break; }
		if (s[rc] == '*' && cntr == 1) { it = rc; break; }
		rc--;
	}
	
	int res1 = dfs(l + 1, it);
	int res2 = dfs(it + 1, r - 1);
	if (s[it] == '*') return AND[res1][res2];
	return OR[res1][res2];
}

int main() {
	while (cin >> s) {
		if (s == ".") break;
		int ans = 0;
		P = Q = R = 0;
		rep(P, 3) rep(Q, 3) rep(R, 3) if (dfs(0, s.length()) == 2) ans++;
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 3188
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<int(n);i++)
#define N 200000


int main(){
	int a[N];
	int n, k;
	int x, y, z;
	long long s, ans;
	s = 0;
	ans = 0;
	scanf("%d %d", &n, &k);
	f(i, n){
		scanf("%d", &a[i]);
		if (a[i] == 1)x = i;
	}
	x--;
	if (x >= 0)y = x / (k - 1);
	else y = -1;
	y++;
	x = n - (y*(k - 1)) - 2;
	if (x >= 0)z = x / (k - 1);
	else z = -1;
	z++;
	y += z;
	printf("%d\n", y);

	return 0;
}

Measured memory_bytes: 512
//https://onlinejudge.u-aizu.ac.jp/challenges/sources/PCK/Prelim/0317?year=2015

#include <bits/stdc++.h>

using namespace std;

int main() {
    int d, l;
    cin >> d >> l;

    cout << d / l + d % l << endl;
    return 0;
}

/*
 *
 */


Measured memory_bytes: 3108
using System;

public class hello
{
    public static string[] a;
    public static void Main()
    {
        a = new string[] { "", "',.!?", "abcABC", "defDEF", "ghiGHI", "jklJKL", "mnoMNO", "pqrsPQRS", "tuvTUV", "wxyzWXYZ" };
        string s;
        for (; (s = Console.ReadLine()) != null;)
        {
            var ans = getAns(s);
            Console.WriteLine(ans);
        }
    }
    static string getAns(string s)
    {
        var ans = "";
        var sL = s.Length;
        var pre = s[0] - '0';
        var count = 1;
        var p = 1;
        while (p < sL)
        {
            var t = s[p] - '0';
            if (t == pre) { count++; }
            else
            {
                if (pre == 0 && count > 1) ans += new string(' ', count - 1);
                else if (pre != 0) ans += a[pre][count - 1];
                count = 1;
            }
            pre = t;
            p++;
        }
        ans += a[pre][count - 1];
        return ans;
    }
}



Measured memory_bytes: 13832
from sys import stdin
import sys
import numpy as np
import collections
from functools import cmp_to_key
import heapq

##  input functions for me
def rsa(sep = ''):
    if sep == '' :
        return input().split() 
    else: return input().split(sep)
def rip(sep = ''):
    if sep == '' :
        return map(int, input().split()) 
    else: return map(int, input().split(sep))
def ria(sep = ''): 
    return list(rip(sep))
def ri(): return int(input())
def rd(): return float(input())
def rs(): return input()
##

def inv(v, mod):
    return pow(v, mod-2, mod)
def main():
    r1, c1, r2, c2 = rip()

    MM = int(2e6+10)
    fact = [0] * MM
    finv = [0] * MM
    fact[0] = 1
    finv[0] = 1
    mod = int(1e9) + 7
    for i in range(1,MM): fact[i] = (fact[i-1] * i % mod)
    '''
    finv[MM-1] = inv(fact[MM-1], mod)
    for i in reversed(range(1,MM-1)):
        finv[i] = finv[i + 1] * (i + 1) % mod
    def sum_naive(r, c):
        #[0, r) * [0, c)
        ret = 0
        for i in range(r):
            ret += fact[i + 1 + c - 1] * finv[i + 1] * finv[c - 1] % mod
        return ret
    def sum(r, c):
        #[0, r) * [0, c)
        ret = fact[r + c] * finv[r] * finv[c] % mod
        ret += -1 + mod
        ret %= mod
        return ret
    '''
    def sum(r, c):
        #[0, r) * [0, c)
        ret = fact[r + c] * inv(fact[r], mod) * inv(fact[c], mod) % mod
        ret += -1 + mod
        ret %= mod
        return ret
    ans = 0
    ans += sum(r2 + 1, c2 + 1)
    ans -= sum(r2 + 1, c1)
    ans -= sum(r1, c2 + 1)
    ans += sum(r1, c1)
    ans %= mod
    print(ans)



if __name__ == "__main__":
    main()


Measured memory_bytes: 106732
#include<cstdio>
using namespace std;
#define N 15005
int a[N],b[N],n,s1,s2;
char s[N],t[N];
long long solve(int t)
{
	long long as=0;
	int fg=0;
	if(t<0){t=-t;fg=1;for(int i=1;i<=n;i++)a[i]^=b[i]^=a[i]^=b[i];s1^=s2^=s1^=s2;}
	int l1=1,r1=1-t;
	while(1)
	{
		int tp1=a[l1],tp2=r1<0?0:b[r1];
		if(l1>s1)tp1=n;if(r1>s2)tp2=n;
		as+=tp1<tp2?tp2-tp1:tp1-tp2;
		if(tp1==tp2&&tp1==n)break;
		l1++,r1++;
	}
	if(fg){for(int i=1;i<=n;i++)a[i]^=b[i]^=a[i]^=b[i];s1^=s2^=s1^=s2;}
	return as;
}
int main()
{
	scanf("%d%s%s",&n,s+1,t+1);
	for(int i=1;i<=n;i++)if(s[i]!=s[i+1])a[++s1]=i;
	for(int i=1;i<=n;i++)if(t[i]!=t[i+1])b[++s2]=i;
	solve(-1);
	long long mn=1e18;for(int i=s[1]==t[1]?-5000:-5001;i<=5000;i+=2){long long tp=solve(i);if(tp<mn)mn=tp;}
	printf("%lld\n",mn);
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
# define ll long long
# define int long long  //comment it out when MLE
//# define endl "\n"
#define gok ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
# define mo 1000000000
# define mm 1000000007
# define pi acos(-1)
# define fi first
# define se second

using namespace std;

signed main()
{
    gok

       int n,m;
       cin>>n>>m;
       int a[m];
       int su=0;
       for(int i=0;i<m;i++){
        cin>>a[i];
        su+=a[i];
       }
       int d = n-su;
       if(d<0)
        cout<<-1;
       else
        cout<<d;



















      return 0;
    }


Measured memory_bytes: 3664
N = gets.chomp.to_i
d = N.to_s.length
cnt = 0
3.upto(d) do |i|
  ['3', '5', '7'].repeated_permutation(i) do |num|
    next if !num.include?('3')
    next if !num.include?('5')
    next if !num.include?('7')
    num = num.join.to_i
    if num <= N
      cnt += 1
    end
  end
end
puts cnt


Measured memory_bytes: 2044
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(a) (a).begin(),(a).end()
#define MOD 100000
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
const int INF=1e9;
int main(){
      int dl,n,m,k,d[100001];
      while(scanf("%d",&dl)&&dl){
            scanf("%d%d",&n,&m);
            d[0]=0;
            REP(i,n-1)scanf("%d",&d[i+1]);
            d[n]=dl;
            sort(d,d+n+1);
            int ans=0;
            REP(i,m){
                  scanf("%d",&k);
                  int lb=-1,ub=n;
                  while(ub-lb>1){
                        int mid=(lb+ub)/2;
                        if(d[mid]>=k){
                              ub=mid;
                        }else{
                              lb=mid;
                        }
                  }
                  ans+=min(abs(d[ub]-k),abs(d[lb]-k));
            }
            printf("%d\n",ans );
      }
}

Measured memory_bytes: 1596
/*786*/
#include <bits/stdc++.h>

#define pu ios_base::sync_with_stdio();cin.tie(NULL);cout.tie(NULL);

#define ll                  long long
#define yes                 cout<<"YES"<<endl
#define no                  cout<<"NO"<<endl
#define sp                  ' '
#define vi                  vector<int>
#define vl                  vector<ll>
#define pb                  push_back
#define mp                  make_pair
#define f(i,n)              for(i=0;i<n;i++)
#define stop                return 0;
#define new                 cout<<endl
#define res(x)              cout<<x<<endl;
#define vip                 vector<pair<int,int> >
#define srt(v)              sort(v.begin(),v.end());
#define test                int t;cin>>t;while(t--)
#define mx(a)               *max_element(a,a+n)

using namespace std;

int main()

{
    pu;
    int r;
    double c;
    cin>>r;
    c=2*3.1416*r;
    printf("%.2lf",c);

    stop;
}


Measured memory_bytes: 3760
#include <stdio.h>
int minx(int v[],int n){
	int i,j,k,tmp;
	tmp=v[0];
	for(i=1;i<=n-1;i++){
		if(tmp>v[i])
		tmp=v[i];}
		return tmp;}
int abs(int n){
		if(n<0){
		return -1*n;}else
		return n;}
int max(int n1,int n2,int n3){
	int tmp;
	tmp=n1;
	if(n2>tmp)
	tmp=n2;
	if(n3>tmp)
	tmp=n3;
	return tmp;}
int min3(int n1,int n2,int n3){
	int tmp;
	tmp=n1;
	if(n2<tmp)
	tmp=n2;
	if(n3<tmp)
	tmp=n3;
	return tmp;}
int main(void)
{int N,A,M,B,j,x,i,k,H,W,l,sum,m,mint,flag;
	scanf("%d",&N);
	int s[100];
	int t[100];
	flag=0;
	sum=0;
	for(i=0;i<=N-1;i++){
		scanf("%d",&s[i]);}
		int w=0;
		for(j=0;j<=N-1;j++){
			sum+=s[j];
			if((s[j]%10)!=0){
				flag=1;
				t[w]=s[j];
				w+=1;}}
		mint=minx(t,w);
	if(flag==0){
		printf("0");}
	else if((sum%10)!=0)
	printf("%d",sum);
	else{
		printf("%d",sum-mint);}




	return 0;
}


Measured memory_bytes: 128
package main
import . "fmt"
import . "strconv"
import . "os"
func main() {
  var a,b string
  Scan(&a)
  Scan(&b)
  if len(a) < len(b) {
    Println("LESS")
  } else if len(a) < len(b) {
    Println("GREATER")
  } else {
    var n,x,y int
    n = len(a)
    for i:=0;i<n;i++ {
      x,_ = Atoi(a[i:i+1])
      y,_ = Atoi(b[i:i+1])
      if x < y {
        Println("LESS")
        Exit(0)
      } else if x > y {
        Println("GREATER")
        Exit(0)
      } else {
        continue
      }
    }
    Println("EQUAL")
  }
}

Measured memory_bytes: 512
#include<iostream>

using namespace std;

typedef long long ll;

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

Measured memory_bytes: 3592
from time import time
from random import randint

from numba import njit
from numpy import int64

@njit('i8(i8[:],i8[:])')
def func(s,x):
    last=[0]*26
    score=0
    for i,v in enumerate(x,1):
        last[v]=i
        c=0
        for j in range(26):
            c+=s[j]*(i-last[j])
        score=score+s[i*26+v]-c
        print(score)
    return score

def main():
    start=time()
    d,*s=map(int,open(0).read().split())
    s=int64(s)
    func(s,s[-d:]-1)
main()

Measured memory_bytes: 111720
n, m, x = map(int, input().split())
L = [list(map(int, input().split())) for _ in range(n)]

ans = float("inf")

for i in range(1<<n):
    cost = 0
    points = [0] * m
    for j in range(n):
        if i>>j & 1:
            cost += L[j][0]
            for k in range(m):
                points[k] += L[j][k+1]

    if min(points) >= x:
        ans = min(ans, cost)

if ans == float("inf"):
    print(-1)

else:
    print(ans)

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

#define pii  pair<int, int>
#define vi vector<int >
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define x first
#define y second
#define sz(x) (x).size()
#define all(x) (x).begin(), (x).end() //Forward traversal
#define rall(x) (x).rbegin, (x).rend() //reverse traversal

#define ll long long
#define ld long double

const ld EPS = 10e-9;
const int INF = 1e9 + 5;
const long long INFLL = (ll)INF * (ll)INF;
const ll MOD = 1e9 + 7;
const ld PI = 3.14159265358979323846;

template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v)
{
    os << "[";
    for (int i = 0; i < (int)v.size(); ++i) {
        os << v[i];
        if (i != (int)v.size() - 1)
            os << ", ";
    }
    os << "]\n";
    return os;
}

template <typename T>
ostream& operator<<(ostream& os, const set<T>& v)
{
    os << "{";
    for (const auto& it : v) {
        os << it;
        if (it != *v.rbegin())
            os << ", ";
    }
    os << "}\n";
    return os;
}

template <typename T>
ostream& operator<<(ostream& os, const unordered_set<T>& v)
{
    os << "{";
    for (const auto& it : v) {
        os << it;
        if (it != *v.rbegin())
            os << ", ";
    }
    os << "}\n";
    return os;
}

template <typename T, typename S>
ostream& operator<<(ostream& os, const map<T, S>& v)
{
    os << "{";
    for (const auto& it : v) {
        os << it.first << " : "
           << it.second;

        if( it != *v.rbegin())
            os  << ", ";
    }

    os << "}\n";
    return os;
}

template <typename T, typename S>
ostream& operator<<(ostream& os, const unordered_map<T, S>& v)
{
    os << "{";
    for (const auto& it : v) {
        os << it.first << " : "
           << it.second;

        if( it != *v.rbegin())
            os  << ", ";
    }

    os << "}\n";
    return os;
}

template <typename T, typename S>
ostream& operator<<(ostream& os, const pair<T, S>& v)
{
    os << "(";
    os << v.first << ", "
       << v.second << ")";
    os << "\n";
    return os;
}

#define DEBUG

#ifdef DEBUG
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define debug(...)
#endif


// __gcd(x, y)

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

    if(s == "ABC")
        cout << "ARC" << endl;
    else
        cout << "ABC" << endl;
    return 0;
}




Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
using Int = long long;
const char newl = '\n';

//INSERT ABOVE HERE
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(0);

  Int n,d;
  cin>>n>>d;
  Int ans=0;
  for(Int i=0;i<n;i++){
    Int x,y;
    cin>>x>>y;
    ans+=x*x+y*y<=d*d;
  }
  cout<<ans<<newl;
  return 0;
}


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

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

  if(s == "SUN") ans = 7; 
  if(s == "MON") ans = 6;
  if(s == "TUE") ans = 5;
  if(s == "WED") ans = 4;
  if(s == "THU") ans = 3;
  if(s == "FRI") ans = 2;
  if(s == "SAT") ans = 1;

  cout << ans << endl;
  

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <cstdio>
#include <ctime>
#include <assert.h>
#include <chrono>
#include <random>
#include <numeric>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
using namespace std;
typedef long long int ll;
typedef unsigned long long ull;

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll myRand(ll B) {
	return (ull)rng() % B;
}

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n,m;
    while(cin >> n >> m,n){
        vector<ll> sum(n,0);
        vector<ll> mi(n,0);
        for(int i=0;i<m;i++){
            ll s; cin >> s;
            int k; cin >> k;
            if(k==1){
                k--;
                int x; cin >> x;
                x--;
                mi[x]+=s;
                sum[x]+=s;
            }
            while(k--){
                int x; cin >> x;
                x--;
                sum[x]+=s;
            }
        }
        ll res=0;
        multiset<ll> ss;
        for(int i=0;i<n;i++){
            ss.insert(mi[i]);
        }
        for(int i=0;i<n;i++){
            ss.erase(ss.find(mi[i]));
            res=max(res,sum[i]-*ss.begin());
            ss.insert(mi[i]);
        }
        printf("%lld\n",res+1);
    }
}


Measured memory_bytes: 3384
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int top, A[1000];

void push(int x){
  top++;
  A[top]=x;
}
int pop(){
  top--;
  return A[top+1];
}

int main(){
int a,b;
top=0;
char s[100];
while (scanf("%s",s)!=EOF) {
  if(s[0]=='+'){
    a=pop();
    b=pop();
    push(a+b);
  }
  else if(s[0]=='-'){
    b=pop();
    a=pop();
    push(a-b);
  }
  else if(s[0]=='*'){
    a=pop();
    b=pop();
    push(a*b);
  }
  else {push(atoi(s));}
}
printf("%d\n",pop());
  return 0;
}


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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using vec_b = vector<bool>;
using vec_str = vector<string>;

#define INF (1LL << 60)
#define MOD 1000000007

#define REP(i,m,n) for(ll (i)=(m),i##_len=(n);(i)<(i##_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define _PR(x) cout << (x) << endl
#define _PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define pb push_back


int main()
{
    ll N, K;
    cin >> N >> K;
    vec H(N);
    REP(i,0,N) cin >> H[i];

    ll m = 0;
    if(N > K) {
        sort(ALL(H), greater<ll>());
        REP(i,K,N) m += H[i];
    }
    _PR(m);

    return 0;
}

/*



*/

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

#define FOR(a, b, c) for(int a = b; a <= c; ++a)
#define FORW(a, b, c) for(int a = b; a >= c; --a)
#define fi first
#define se second
#define pb push_back
#define int long long

typedef pair<int, int> ii;
typedef pair<int, ii> iii;

const int N = 1e5 + 100;
const int maxN = 1e16;
const int oo = 1e18;
const int mod  = 998244353;

int n;
int f[N], g[N];

signed main()
{
    ios_base::sync_with_stdio(false); cin.tie(0);
    cin >> n;
    int sum = 0;
    FORW(i, n, 1) {
        int cnt = (n - i) / i + 1;
        f[i] += 1ll * cnt * cnt * cnt;
        FOR(j, 1, sqrt(i)) if(i % j == 0) {
            if(i > 1) f[j] -= f[i];
            if(j > 1 && j * j != i) f[i / j] -= f[i];
        }
    }

    FOR(i, 1, n) sum += f[i] * i;
    cout << sum;
}


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

int main() {
    vector<int> A(3);
    cin >> A.at(0) >> A.at(1) >> A.at(2);
    sort(A.begin(),A.end());
  
    int a,b,c;
    a=A.at(0);
    b=A.at(1);
    c=A.at(2);

    int ans;
    if((b - a) % 2 == 0) ans= c - b + (b - a) / 2;
    else ans= c - b + (b - a) / 2 + 2;
    
    cout << ans << endl;
}

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

for i in range(h):
    S[i] = list(input())

base = 1
for hi in range(h):
    if '#' in S[hi]:
        t = False
        for wi in range(w):
            if S[hi][wi]=='#':
                if t:
                    for wii in range(wi):
                        ans[hi][wii] += 1
                else:
                    t = True
                    for wii in range(w): ans[hi][wii] = base
        base = max(max(ans))+1

for wi in range(w):
    chi = [ans[hi][wi] for hi in range(h) if ans[hi][wi]!=0]
    nowchi = 0
    for hi in range(h):
        if ans[hi][wi]==0:
            ans[hi][wi] = chi[nowchi]
        elif ans[hi][wi]==chi[nowchi] and nowchi<len(chi)-1:
            nowchi += 1

for _ans in ans:
    print(*_ans)

Measured memory_bytes: 13456
#include <iostream>
#include <string>
#include <vector>
#include <unordered_map>
#include <algorithm>
 
using namespace std;
 
void addWordCount(const vector<string>& cards, unordered_map<string, int>& wordCount);
void subWordCount(const vector<string>& cards, unordered_map<string, int>& wordCount);
  
int main() {
    int numOfBlueCard = 0;
    cin >> numOfBlueCard;
    vector<string> blueCards;
    for (int i = 0; i < numOfBlueCard; ++i) {
        string blueCard;
        cin >> blueCard;
        blueCards.push_back(blueCard);
    }
 
    int numOfRedCard = 0;
    cin >> numOfRedCard;
    vector<string> redCards;
    for (int i = 0; i < numOfRedCard; ++i) {
        string redCard;
        cin >> redCard;
        redCards.push_back(redCard);
    }
    
    unordered_map<string, int> wordCount;
    addWordCount(blueCards, wordCount);
    subWordCount(redCards, wordCount);
    
    unordered_map<string, int>::iterator maxValueWord = std::max_element(wordCount.begin(), wordCount.end(),
    [](const pair<string, int>& p1, const pair<string, int>& p2) {
        return p1.second < p2.second; });
    
    int maxValue = 0;
    if (maxValueWord->second >= 0) {
        maxValue = maxValueWord->second;
    }
    cout << maxValue << endl;
}
 
void addWordCount(const vector<string>& cards, unordered_map<string, int>& wordCount) {
    for (string card : cards) {
        ++wordCount[card];
    }
}
 
void subWordCount(const vector<string>& cards, unordered_map<string, int>& wordCount) {
    for (string card : cards) {
        --wordCount[card];
    }
}
 

Measured memory_bytes: 3548
#include<bits/stdc++.h>
#define REPI(i, n) for(int i = 0; i < n; i++)
using namespace std;
int main(){
    cin.tie(0);

    map<string, int> s;
    string str;
    int n; cin >> n;
    while(n--){
        cin >> str;
        s[str]++;
    }
    int m; cin >> m;
    while(m--){
        cin >> str;
        s[str]--;
    }
    int ans = 0;
    for(auto a : s) ans = max(ans, a.second);
    cout << ans;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=(ll)1e9+7;


int main() {
    int N;
    cin>>N;
    vector<int> a(N);
    for (int i = 0; i < N; ++i) {
        cin>>a[i];
    }
    sort(a.rbegin(),a.rend());

    int a1=a[0],a2,dist=2e9+5;

    for (int i = 1; i < N; ++i) {
        if(abs(a[i]*2-a1)<dist){
            dist=abs(a[i]*2-a1);
            a2=a[i];
        }
    }
    cout<<a1<<" "<<a2<<endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define l long
#define pb push_back
ll dp[2005][2005];
ll M=1e9+7;
int main() {
	// your code goes here
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
	int n,m;
	cin>>n>>m;
	int a[n],b[m];
	for(int i=0;i<n;i++) cin>>a[i];
	for(int i=0;i<m;i++) cin>>b[i];
	for(int i=0;i<2005;i++) dp[i][0]=1;
	for(int i=0;i<2005;i++) dp[0][i]=1;
	for(int i=1;i<=n;i++)
	{
	    for(int j=1;j<=m;j++)
	    {
	        if(a[i-1]==b[j-1]){ dp[i][j]=(dp[i][j-1]+dp[i-1][j])%M; }
	        else{ dp[i][j] = (dp[i-1][j]+dp[i][j-1]-dp[i-1][j-1] + M)%M; } 
	    }
	}    
	cout<<dp[n][m]%M;    
	return 0;
}


Measured memory_bytes: 31616
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <algorithm>
using namespace std;
#define ll long long
int main (){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << min(a, b)+min(c, d) << endl;
    return 0;
}


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

int arr[100005];

int main()
{
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>arr[i];
    deque<int> A;
    deque<int> B;
    deque<int> C;
    for(int i=0;i<n;i++){
        if(arr[i]%2==1)A.push_back(arr[i]);
        if(arr[i]%4==0){
           B.push_back(arr[i]);
           continue;
        }
        if(arr[i]%2==0)
            C.push_back(arr[i]);
    }
    if(B.size()>=A.size()){
        cout<<"Yes";
        return 0;
    }
    else{
        if(A.size()-1==B.size() && C.empty()){
            cout<<"Yes";
            return 0;
        }
        cout<<"No";
        return 0;
    }
    cout<<"No";

}


Measured memory_bytes: 1024
from itertools import combinations
n=int(input())
A=list(map(int,input().split()))
C=[]
for i in range(1,n+1):
  C+=list(map(sum,combinations(A,i)))
q=int(input())
M=list(map(int,input().split()))
for m in M:
  print("yes" if m in C else "no")


Measured memory_bytes: 44276
#include <iostream>

using namespace std;

int main (void) {
    char c;
    cin >> c;

    if ( c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u' )
        cout << "vowel" << endl;
    else
        cout << "consonant" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cassert>
#include <exception>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<P> vp;
#define rep(i,a,n) for(ll i = (a);i < (n);i++)
#define per(i,a,n) for(ll i = (a);i > (n);i--)
#define lep(i,a,n) for(ll i = (a);i <= (n);i++)
#define pel(i,a,n) for(ll i = (a);i >= (n);i--)
#define clr(a,b) memset((a),(b),sizeof(a))
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define sz size()
#define print(X) cout << (X) << endl
const ll INF = 1e+9+7;
ll n,m,l;
string s,t;
ll d[200010],dp[550][550];

int main(){
  s = "Yes";
  rep(i,0,3)rep(j,0,3)cin >> dp[i][j];
  rep(i,0,3)rep(j,1,3)dp[i][j] -= dp[i][0];
  rep(j,1,3)rep(i,1,3)if(dp[i][j] != dp[i-1][j])s = "No";
  print(s);
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
const double PI = acos(-1);
#define rep(i, n) for (int i = 0; i < (int)(n); i++ )
using namespace std;
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}
int main(){
  string s, t;
  cin >> s >> t;
  int n = s.size();
  string s2 = s;
  char begin ,end;
  rep(i,s.size()){
    if( s == t){
      cout << "Yes" << endl;
      break;
    }
    s2.at(0) = s.at(s.size()-1);
    for(int i = 1;i<n;i++){
      s2.at(i) = s.at(i-1);
    }
    s = s2;
    if(i == s.size()-1){
      if(s == t) cout << "Yes" << endl;
      else cout << "No" << endl;
    }
  }
}

Measured memory_bytes: 3556
// AOJ 0525: Osenbei
// 2017.11.12 bal4u@uu

#include <stdio.h>
#include <stdlib.h>

char b[2][10][20010], *a[10];
char buf[20010];

int main()
{
	int r, c, i, j, k, jj, s, lim, cnt, ans;
	char *p;

	while (fgets(p=buf, 20, stdin) && *p != '0') {
		r = atoi(p); while (*p >= '0') p++;
		c = atoi(p);
		for (j = 0; j < r; j++) {
			fgets(p=buf, 20010, stdin);
			for (i = 0; i < c; i++) {
				b[1][j][i] = *p++ & 1, p++;
				b[0][j][i] = 1-b[1][j][i];
			}
		}

		ans = 0, lim = 1 << r;
		for (k = 0; k < lim; k++) {
			for (jj = 1, j = 0; j < r; j++, jj <<= 1) a[j] = b[!(k & jj)][j];
			for (cnt = 0, i = 0; i < c; i++) {
				for (s = 0, j = 0; j < r; j++) s += a[j][i];
				if (s < r-s) s = r-s;
				cnt += s;
			}
			if (cnt > ans) ans = cnt;
		}
		printf("%d\n", ans);
	}
	return 0;
}

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

int N;
int A[210];


int main() {
  cin >> N;
  for(int i = 0; i < N; ++i) cin >> A[i];
  
  int res = 1000000000;

  for(int i = 0; i < N; ++i) {
    int cnt = 0; // 2で割れる回数
    while(true) {
      if(A[i]%2==0){
        A[i]/=2;
        ++cnt;
      }
      else break;
    }
    if(cnt < res) res = cnt;
  }
  cout << res << endl;

}

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

int main()
{
    int c[3][3], n = 3;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            cin >> c[i][j];
        }
    }

    for (int j = 0; j < n - 1; j++) {
        set<int> se;
        for (int i = 0; i < n; i++) {
            se.insert(c[i][j] - c[i][j + 1]);
        }
        if (se.size() > 1) return cout << "No" << endl, 0;
    }
    for (int i = 0; i < n - 1; i++) {
        set<int> se;
        for (int j = 0; j < n; j++) {
            se.insert(c[i][j] - c[i + 1][j]);
        }
        if (se.size() > 1) return cout << "No" << endl, 0;
    }
    
    cout << "Yes" << endl;

    return 0;
}


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

using namespace std;

int main()
{
    int N;
    string str;
    
    cin >> str;
    cin >> N;
    
    for(int i = 0; i < N; ++i)
    {
        int l, r;
        string op;
        cin >> op >> l >> r;
        
        if(op == "print")
        {
            for(int j = l; j <= r; ++j)
            {
                cout << str[j]; 
            }
            cout << endl;
        }
        else if(op == "replace")
        {
            string rep;
            cin >> rep;
            str = str.replace(l, r-l+1, rep);
        }
        else 
        {
            string rep;
            for(int j = r; j >= l; --j)
            {
                rep += str[j];
            }
            str = str.replace(l, r-l+1, rep);
        }
    
    }
    
    
    return 0;
}


Measured memory_bytes: 3208
#ifdef DEBUG_IS_VALID
#define DEB 1 
#define _LIBCPP_DEBUG 0
#else
#define DEB 0
#define NDEBUG
#endif

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

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i, x, n) for(int i = x; i >= n; i--)
#define rrep(i, n) RREP(i,n,0)
#define pb push_back
#define fi first
#define se second
#pragma GCC optimize ("-O3")

using namespace std;

#define DUMPOUT cout
#define dump(...) if(DEB) DUMPOUT<<"  "<<#__VA_ARGS__<<" :["<<__LINE__<<":"<<__FUNCTION__<<"]"<<endl<<"    "; if(DEB) dump_func(__VA_ARGS__)
template<typename T1,typename T2>ostream& operator << (ostream& os, pair<T1,T2> p){cout << "(" << p.first << ", " << p.second << ")"; return os;}
template<typename T>ostream& operator << (ostream& os, vector<T>& vec) { os << "{"; for (int i = 0; i<vec.size(); i++) os << vec[i] << (i + 1 == vec.size() ? "" : ", "); os << "}"; return os; }
template<typename T>ostream& operator << (ostream& os, set<T>& st){cout << "{"; for(auto itr = st.begin(); itr != st.end(); itr++) cout << *itr << (next(itr)!=st.end() ? ", " : ""); cout << "}"; return os;}
template<typename T1,typename T2>ostream& operator << (ostream& os, map<T1,T2> mp){cout << "{"; for(auto itr = mp.begin(); itr != mp.end(); itr++) cout << "(" << (itr->first) << ", " << (itr->second) << ")" << (next(itr)!=mp.end() ? "," : ""); cout << "}"; return os; }

void dump_func(){DUMPOUT << endl;}
template <class Head, class... Tail>void dump_func(Head&& head, Tail&&... tail){ DUMPOUT << head; if (sizeof...(Tail) == 0) { DUMPOUT << " "; } else { DUMPOUT << ", "; } dump_func(std::move(tail)...);}
template<class T> inline bool chmax(T& a,T const& b){if(a>=b) return false; a=b; return true;}
template<class T> inline bool chmin(T& a,T const& b){if(a<=b) return false; a=b; return true;}

using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vp = vector<Pl>;
using vvp = vector<vp>;

const int INF = 1<<29;
const long long LINF=1LL<<59;


void solve(std::string S){
   vector<string> wek = {"SUN","MON","TUE","WED","THU","FRI","SAT"};
   vector<ll> ans = {7,6,5,4,3,2,1};
   rep(i,7){
     if(S==wek[i]){
       cout << ans[i] << endl;
     }
   }
}

int main(){
  std::cout << std::fixed << std::setprecision(15);
  std::string S;
  std::cin >> S;
  solve(S);
  return 0;
}


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

int main(void){
  int n; cin >> n;
  string s; cin >> s;

  int dp=0;

  for(int i=1;i<s.size();i++){
    string x = s.substr(0,i);
    string y = s.substr(i,s.size());
    sort(x.begin(),x.end());
    sort(y.begin(),y.end());
    auto aft_x = unique(x.begin(),x.end());
    auto aft_y = unique(y.begin(),y.end());
    x.erase(aft_x,x.end());
    y.erase(aft_y,y.end());
    int count=0;
    for(int j=0;j<x.size();j++){
      char inx = x[j];
      for(int k=0;k<y.size();k++){
	char iny = y[k];
	if(inx==iny) count++;
      }
    }
    dp=max(count,dp);
  }

  cout << dp << endl;
  
  return 0;
}


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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

void solve() {
    // cout << ans << "\n";
    int a,b;
    cin >> a >> b;

    string intstr;
    int count = 0;
    int len;
    for(int i=a;i<=b;i++){
        len = to_string(i).length();
        int c;
        c = int(len/2);
        string pre,aft;
        pre =  to_string(i).erase(c);
        if (len % 2 == 0) {
            aft =  to_string(i).substr(c);
        }else{
            aft = to_string(i).substr(c+1);
        }
        reverse(aft.begin(),aft.end());
        if(pre.compare(aft) == 0){
            count++;
        }
    }
    cout << count << endl;
}

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

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
using namespace std;

int main()
{

    long long int temp = 0, N, i;
    cin >> N;

    for (i = 1; i < (N / 10) + 5; i++)
    {
        if ((pow(i, 2)) <= N)
        {
            temp = pow(i, 2);
        }
        else
        {
            break;
        }
    }
    cout << temp;
    return 0;
}


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

using namespace std;

const int mod=1e9+7;
long long dp[700][2002];

long long DP(int cur,long long sum)
{
    if(sum == 0)return dp[cur][0]=1;
    if(sum < 3)return dp[cur][sum]=0;
    long long &ans=dp[cur][sum];
    if(ans > -1)return ans;
    ans=0;
    for(int i=3;i<=sum;i++)ans=(ans+DP(cur+1,sum-i))%mod;
    return ans;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    int n;
    memset(dp,-1,sizeof(dp));
    cin >> n;
    cout << DP(1,n);
    return 0;
}


Measured memory_bytes: 14564
# 再帰上限あげとく
import sys
sys.setrecursionlimit(10**6)

# 値入力
mod = 7+10**9
N,M = map(int, input().split())
a = [0]*M
for i in range(M):
    a[i] = int(input())

# メモ化フィボナッチ
# 参考:http://python-remrin.hatenadiary.jp/entry/2017/05/19/153228
memo = [0]*(N+2)
def fibonacci(n):
    if n < 3:
        return 1
    if memo[n] < 1:
        memo[n] = fibonacci(n-1) + fibonacci(n-2)
    return memo[n]

now = 0 # 今いる場所と考える
count = 1
for i in a:
    count *= fibonacci(i-now)
    count = count%mod
    if now == i:
        print(0)
        quit()
    now = i+1 # 穴を超えた次の段に移動する

# 最上段までを計算
count *= fibonacci(N-now+1)
print(count%mod)

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

typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define dump(x)  cout << #x << " = " << (x) << endl;	//debug
#define SZ(x) ((int)(x).size())
#define REP(i, n) for(ll i = 0; i < (n); i++)
#define REPR(i, n) for (ll i = (n); i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)

int main() {
	ll s,w;
	ll res = 0;
	cin >> s >> w;
	if (w >= s) {
		cout << "unsafe" << endl;
	}
	else {
		cout << "safe" << endl;
	}
	return(0);
}

Measured memory_bytes: 3636