akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 1000000007; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;


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

  if(A%2 == 1 || B%2 == 1 || C%2 == 1){
    cout << 0 << endl;
  }
  else if(A == B && B == C){
    cout << -1 << endl;
  }else{
    int ans = 0;
    while(A%2 == 0 && B%2 == 0 && C%2 == 0){
      int AA = A/2;
      int BB = B/2;
      int CC = C/2;
      A = BB+CC; B = CC+AA; C = AA+BB;
      ans++;
    }
    cout << ans << endl;
  }


  return 0;
}

Measured memory_bytes: 256
N, K = map(int, input().split())

# 2a = xk, 2b = ykのとき a+b = (x+y)k/2
# x+yが偶数、すなわちx,yの偶奇が一致するならばa+bはkの倍数となる。他の組合せでも同様
# a,b,cの候補リストを用意して重複順列計算

abc_list_even = []
abc_list_odd = []

for a in range(1, N+1):
    if (2*a)%K == 0:
        if ((2*a)//K)%2 == 0:
            abc_list_even.append(a)
        else:
            abc_list_odd.append(a)

print(len(abc_list_even)**3 + len(abc_list_odd)**3)

Measured memory_bytes: 11032
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr long long MOD = 1000000007;
constexpr long long INF = 1LL << 60;
const long double PI = acosl(-1.0);
constexpr long double EPS = 1e-11;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main(){
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << max({b * d, a * c, b * c, a * d}) << endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define int long long
#define INF 1000000000000000000
using namespace std;

typedef vector<int> vec;
typedef vector<vec> mat;
typedef pair<int, int> Pii;

template<typename T>
void readvec(vector<T> &a);
void readindex(vector<int> &a);



signed main(){

    int N; cin >> N;
    vec p(N); readindex(p);
    vec invp(N); REP(i, N) invp[p[i]] = i;

    vec a(N), b(N);
    REP(i, N){
        a[i] = N * (i + 1) + invp[i];
        b[i] = N * (N - i);
    }
    REP(i, N) cout << a[i] << " ";
    cout << endl;
    REP(i, N) cout << b[i] << " ";
    
    return 0;
}


template<typename T>
void readvec(vector<T> &a){
    REP(i, a.size()){
        cin >> a[i];
    }
}
void readindex(vector<int> &a){
    REP(i, a.size()){
        cin >> a[i];
        a[i]--;
    }
}

Measured memory_bytes: 1280
using System;
using System.Linq;

namespace ConsoleApp3
{
    internal class Class2
    {
        private static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var abs = Enumerable.Range(0, n).Select(_ =>
            {
                var ab = Console.ReadLine().Split().Select(int.Parse).ToArray();
                return (A: ab[0], B: ab[1]);
            })
            .ToArray();

            if (n < 3)
            {
                Console.WriteLine("No");
            }
            else
            {
                var ohYeah = false;
                var ohYeah2 = false;
                var ohYeah3 = false;
                foreach (var (a, b) in abs)
                {
                    if (a == b)
                    {
                        if (!ohYeah)
                        {
                            ohYeah = true;
                        }
                        else if (!ohYeah2)
                        {
                            ohYeah2 = true;
                        }
                        else
                        {
                            ohYeah3 = true;
                        }

                        if (ohYeah3)
                        {
                            Console.WriteLine("Yes");
                            return;
                        }
                    }
                    else
                    {
                        ohYeah = false;
                        ohYeah2 = false;
                        ohYeah3 = false;
                    }
                }

                Console.WriteLine("No");
            }
        }
    }
}

Measured memory_bytes: 28352
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		while(true){
			int n = stdIn.nextInt();
			int a = stdIn.nextInt();
			int b = stdIn.nextInt();
			int c = stdIn.nextInt();
			int x = stdIn.nextInt();
			if((n|a|b|c|x)==0){
				return;
			}
			int[] y = new int[n];
			for(int i=0;i<n;i++){
				y[i] = stdIn.nextInt();
			}
			int cnt = 0;
			int idx = 0;
			while(true){
				if(cnt>10000){
					System.out.println(-1);
					break;
				}
				if(x==y[idx]){
					idx++;
				}
				if(idx==y.length){
					System.out.println(cnt);
					break;
				}
				cnt++;
				int x_ = (a*x+b)%c;
				x = x_;
			}
		}
	}
}

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

using namespace std;

#define llong long long int
#define ldouble long double
#define ternary(condition, x, y) ((condition) ? x : y) 
#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) x.begin(), x.end()
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)

const static llong MOD = 1000000000 + 7;
const static int dy[] = {0, 1, 0, -1};
const static int dx[] = {1, 0, -1, 0};

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

    int a, b, c, d, e, f;
    cin >> a >> b >> c >> d >> e >> f;
    double concentration = -1;
    int ans_sum = 0, ans_sugar = 0;
    for (int i = 0; i <= f / (100 * a); ++i) {
        for (int j = 0; 100 * b * j <= f - 100 * a * i; ++j) {
            int water = 100 * a * i + 100 * b * j;
            int sugar_can_be_dissolved = (a * i + b * j) * e;
            // cout << water << " " << sugar_can_be_dissolved << endl;
            // cout << "sum " << water + sugar_can_be_dissolved << " sugar " << sugar_can_be_dissolved << " water " << water << endl;
            for (int k = 0; k <= (f - water) / c; ++k) {
                for (int l = 0; d * l <= (f - water) - c * k; ++l) {
                    // cout << "sum " << water + sugar_can_be_dissolved << " sugar " << sugar_can_be_dissolved << " water " << water << " c " << k * c << " d " << l * d <<  " sum " << k * c + l * d << endl;
                    double tmp = ((double)k * c + l * d) / ((double)water + k * c + l * d);
                    tmp *= 100.0;
                    if (tmp >= concentration && (k * c + l * d) <= sugar_can_be_dissolved) {
                        ans_sum = water + k * c + l * d;
                        ans_sugar = k * c + l * d;
                        concentration = tmp;
                    }
                }
            }
        }
    }

    cout << ans_sum << " " << ans_sugar << endl;

    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using ull=unsigned long long int;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
const ll mod=1000000007;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int main(){
  int t;
  cin>>t; 
while(t--){
string s,t;
cin>>s>>t;
ll now=1;
ll a=0,b=0;
for(int i=0;i<s.size();i++){
  if(s[i]<'a')now=ll(s[i]-'0');
  else {
    if(s[i]=='m')a+=now*1000;
    if(s[i]=='c')a+=now*100;
    if(s[i]=='x')a+=now*10;
    if(s[i]=='i')a+=now;
    now=1;
  }
}
now=1;
for(int i=0;i<t.size();i++){
  if(t[i]<'a')now=ll(t[i]-'0');
  else {
    if(t[i]=='m')b+=now*1000;
    if(t[i]=='c')b+=now*100;
    if(t[i]=='x')b+=now*10;
    if(t[i]=='i')b+=now;
    now=1;
  }
}
ll sum=a+b;
V<char> tmp;
int cnt=0;
while(sum){
  cnt++;
  if(sum%10==0){
    sum/=10;
    continue;
  }
  if(cnt==1)tmp.emplace_back('i');
  if(cnt==2)tmp.emplace_back('x');
  if(cnt==3)tmp.emplace_back('c');
  if(cnt==4)tmp.emplace_back('m');
  if(sum%10!=1&&cnt!=4)tmp.emplace_back(char('0'+sum%10));
  if(sum!=1&&cnt==4){
    if(sum/10==0){
      if(sum%10!=1)tmp.emplace_back(char('0'+sum%10));
    }else{
      tmp.emplace_back(char('0'+sum%10));
      sum/=10;
      tmp.emplace_back(char('0'+sum));
    }
  }
  sum/=10;
}
reverse(all(tmp));
for(int i=0;i<tmp.size();i++)cout<<tmp[i];
cout<<"\n";
}
}


Measured memory_bytes: 3232
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <vector>

#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define all(v) begin(v), end(v)
#define debug(x) cerr<< #x <<": "<<x<<endl
#define debug2(x,y) cerr<< #x <<": "<< x <<", "<< #y <<": "<< y <<endl

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
template<class T> using vv=vector<vector< T > >;

ll po(ll x, ll n) {
  if (n == 0) {
    return 1;
  }
  ll x2 = po(x*x, n/2);
  if (n % 2 == 0) {
    return x2;
  } else {
    return x * x2;
  }
}

int main() {
  ll n, a;
  scanf("%lld %lld", &n, &a);
  vll ans(41, 0);
  ll ansmin = 1e15;
  rep (i, 41) {
    ll s = ceil(pow(n, (1.0 / (i+1))));
    ll maybig = po(s, i+1);
    int cnt = 0;
    while (true) {
      maybig = maybig / s * (s-1);
      if (maybig >= n) {
        cnt += 1;
      } else {
        break;
      }
    }
    ans[i] = a * i + s * (i+1) - cnt;
    ansmin = min(ansmin, ans[i]);
  }
  printf("%lld\n", ansmin);

  return 0;
}


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

using namespace std;
typedef long long ll;

#ifdef _DEBUG
#define DEBUG(x) cout << #x << ": " << x << endl;
#else
#define DEBUG(x)
#endif

#define ALL(obj) (obj).begin(), (obj).end()
#define BIT(n) (1LL << (n))

const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    // write code below
    int N;
    cin >> N;
    vector<int> L(N);
    for (int i = 0; i < N; i++)
    {
        cin >> L.at(i);
    }
    int res = 0;
    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < N; j++)
        {
            for (int k = 0; k < N; k++)
            {
                int a = L.at(i);
                int b = L.at(j);
                int c = L.at(k);

                if (a == b || b == c || c == a)
                {
                    continue;
                }

                if (max(b - c, c - b) < a && a < b + c)
                {
                    res++;
                }
            }
        }
    }
    cout << res / 6 << endl;

    // write code above
    return 0;
}


Measured memory_bytes: 3588
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------
int main(void){
    int h, n;
    cin >> h >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];

    ll total = 0;
    for(int i = 0; i < n; i++){
        total += a[i];
    }

    if(total >= h){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

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

int main(){
  int N,L;
  cin >> N >> L;
  vector<string> words(N);
  for(int i = 0; i < N; i++){
    cin >> words[i];
  }
  sort(words.begin(),words.end());
  for(int i = 0; i < words.size(); i++){
    cout << words[i] ;
  }
  cout << endl;
  return 0;
}


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

int main(){
int N,K;
  cin>>N>>K;
  vector<int>l(N);
  for(int i=0; i<N; i++){
   cin>>l[i]; }
  
  sort(l.begin(), l.end());
  reverse(l.begin(), l.end());
  int ans=0;
  for(int i=0; i<K; i++){
   ans+=l[i];
  }
  
  cout<<ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define endl "\n"
#define fo for(int i=0;i<n;i++)
#define clear cin.clear();cin.ignore(numeric_limits<streamsize>::max(), '\n');
//INT_MAX         2,147,483,647                       <10^10
//U_INT_MAX       4,294,967,295                       <10^10
//LONG_LONG_MAX   9,223,372,036,854,775,807           <10^18
//U_LONG_LONG_MAX 18,446,744,073,709,551,615          <10^18
/*ll power(int a, int b){
    return (ll)(pow(a,b)+0.5);
}*/

/*vector<int> gV(int n){
    vector<int> v;
    int input;
    fo { cin>>input; v.pb(input); }
    return v;
}*/

int* gA(int n){
    int* arr = new int[n];
    fo cin>>arr[i];
    return arr;
}



void solve(){

}


int main() {
	ios_base::sync_with_stdio(false);
    std::cin.tie(NULL);
    std::cout.tie(NULL);

    string s1,s2;
    cin>>s1>>s2;
    int count =0;
    int bitset1[26]={0};
    int bitset2[26]={0};
    for(int i=0;i<s1.length();i++){
        if(s1[i]!=s2[i])
            count++;
    }

    cout<<count<<endl;
	return 0;
}


Measured memory_bytes: 3824
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<numeric>
#include<algorithm>
#include<tuple>
#include<cmath>

typedef unsigned long long ll;

ll DENOM = 1000000000LL + 7LL;
using namespace std;

int main(){
    ll n;
    cin >> n;
    ll ret = 0;
    for (ll i=1; i<n+1; ++i){
        ll nn = n/i;
        ret += i * nn * (nn + 1) / 2LL;
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 3196
using System;
using System.Collections.Generic;
using System.Linq;
using console = System.Console;

namespace AtCoderTemplate
{
    public class App
    {
        public static void Main(string[] args)
        {
            console.ReadLine();
            var p = console.ReadLine().Split().Select(i=>int.Parse(i));
            int t = 0;
            console.WriteLine(p.Skip(1).Zip(p,(a,b)=>a==b).Select(i=>{if(i) t++; else t=0;return t;}).Count(i=>i%2==1));
            
        }
    }
}

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

typedef long long ll;

ll mod_pow(ll x, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}

int main() {
    ll N, M, K, MOD = 998244353, ans = 0;
    cin >> N >> M >> K;
    vector<ll> f(N + 1, 1);
    rep(i, N) f[i + 1] = (f[i] * (i + 1)) % MOD;
    rep(i, K + 1) {
        ll x = M * mod_pow(M - 1, N - 1 - i, MOD);
        x %= MOD;
        x *= f[N - 1];
        x %= MOD;
        x *= mod_pow(f[i], MOD - 2, MOD);
        x %= MOD;
        x *= mod_pow(f[N - 1 - i], MOD - 2, MOD);
        x %= MOD;
        ans = (ans + x) % MOD;
    }
    cout << ans << "\n";
}

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

using namespace std;

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,n) for(int i=1;i<=(int)(n);i++)
#define rep3(i,n) for(int i=0;i<=(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
#define repll(i,n) for(ll i=0;i<(ll)(n);i++)
#define repll2(i,n) for(ll i=1;i<=(ll)(n);i++)
#define REPLL(i,m,n) for(ll i=m;i<(ll)(n);i++)
#define INF 1000000000 //
#define LINF (ll)4000000000000000000 //
#define MOD (ll)1000000007
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define PI 3.1415926535898
#define NP(v) next_permutation(v.begin(),v.end())

//------------------------------------------------------

int main() {
    int a, b;
    cin >> a >> b;
    int cnt = 0;

    REP(i, a, b + 1) {
        string s = to_string(i);
        if (s[0] == s[4] && s[1] == s[3]) cnt++;
    }

    cout << cnt << endl;

    return 0;
}



Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))

if N%2==0:
    ans1 = A[1::2][::-1]
    ans2 = A[0::2]
else:
    ans1 = A[0::2][::-1]
    ans2 = A[1::2]

print(" ".join(map(str,ans1))," ".join(map(str,ans2)))

Measured memory_bytes: 25156
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
using namespace std;

int n,m;

int main(){
	scanf("%d %d",&n,&m);
	int temp=m/n;
	for(int i=temp;i>=1;i--)
		if(m%i==0){
			printf("%d\n",i);
			return 0;
		}
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cstdio>
using namespace std;
long double p1, p2;
int main() {
	cin >> p1 >> p2;
	printf("%.15Lf\n", 1 / ((1 / p1) + (1 / p2)));
	return 0;
}

Measured memory_bytes: 256
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce


sys.setrecursionlimit(2147483647)
INF = 10 ** 20
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


n, k = LI()
A = [0] + LI()

for i in range(1, n + 1):
    A[i] = (A[i] + A[i - 1] - 1) % k


ans = 0
D = defaultdict(int)
for j in range(n, -1, -1):
    ans += D[A[j]]
    D[A[j]] += 1
    if j + k - 1 < n + 1:
        D[A[j + k - 1]] -= 1


if k == 1:
    print(0)
else:
    print(ans)


Measured memory_bytes: 86472
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <vector>
#include <unordered_map>
#include <numeric>
#include <algorithm>
#define rep(it, ifrom, ito) for (auto it = ifrom; it != ito; ++it)
#define all(a) a.begin(), a.end()

using namespace std;

int main(int argc, char* argv[]) {
    const char* debug_env = getenv("DEBUG");
    const bool debug = debug_env && atoi(debug_env) != 0;

    int N;
    cin >> N;

    int count = 0;
    for (int i = 1; i <= N; ) {
        int v = i;
        int c3 = 0, c5 = 0, c7 = 0;
        int fail_m = -1;
        int m = 1;
        while (v > 0) {
            int d = v % 10;
            if (d == 3) ++c3;
            else if (d == 5) ++c5;
            else if (d == 7) ++c7;
            else {
                fail_m = m;
                break;
            }
            v /= 10;
            m *= 10;
        }
        if (fail_m < 0) {
            if (c3 > 0 && c5 > 0 && c7 > 0) {
                ++count;
            }
            ++i;
        } else {
            // 失敗した最下位の桁を動かす
            // それ以下の桁は0から始める
            if (debug) cout << i << " " << fail_m << endl;
            i = (i / fail_m + 1) * fail_m;
        }
    }

    cout << count << endl;
    return 0;
}



Measured memory_bytes: 256
using LIB;
using System;
using System.Linq;
using System.Text;
using System.Collections.Generic;

class Program
{
    public static IO IO = new IO();
    static void Main(string[] args)
    {
        string[] n = IO.STRING(' ');
        Stack<string> s = new Stack<string>();
        for (int i = 0; i < n.Count(); i++)
        {
            if (n[i] == "+")
            {
                s.Push((int.Parse(s.Pop()) + int.Parse(s.Pop())).ToString());
            }
            else if (n[i] == "-")
            {
                int n1 = int.Parse(s.Pop());
                int n2 = int.Parse(s.Pop());
                s.Push((n2 - n1).ToString());
            }
            else if (n[i] == "*")
            {
                s.Push((int.Parse(s.Pop()) * int.Parse(s.Pop())).ToString());
            }
            else
            {
                s.Push(n[i]);
            }
        }
        IO.WRITE(s.Pop());
        IO.FLUSH();
    }
}

namespace LIB
{
    public class IO
    {
        private const int WMAX = 1000;
        private StringBuilder S = new StringBuilder();
        private T R<T>(Func<string, T> f) { return f(Console.ReadLine()); }
        private T[] R<T>(Func<string, T> f, char c) { return STRING().Split(c).Select(f).ToArray(); }
        private T[] R<T>(Func<string, T> f, int l) { T[] r = new T[l]; for (int i = 0; i < l; i++) { r[i] = R(f); } return r; }
        private T[][] R<T>(Func<string, T> f, int l, char c) { T[][] r = new T[l][]; for (int i = 0; i < l; i++) { r[i] = R<T>(f, c); } return r; }
        private void W<T>(Func<T, string> f, T v, bool lf = true) { S.Append(f(v)); if (lf == true) { S.Append('\n'); } if (S.Length >= WMAX) { FLUSH(); } }
        public string STRING() { return R(s => s); }
        public string[] STRING(char c) { return R(s => s, c); }
        public string[] STRING(int l) { return R(s => s, l); }
        public string[][] STRING(int l, char c) { return R(s => s, l, c); }
        public int INT() { return R(int.Parse); }
        public int[] INT(char c) { return R(int.Parse, c); }
        public int[] INT(int l) { return R(int.Parse, l); }
        public int[][] INT(int l, char c) { return R(int.Parse, l, c); }
        public long LONG() { return R(long.Parse); }
        public long[] LONG(char c) { return R(long.Parse, c); }
        public long[] LONG(int l) { return R(long.Parse, l); }
        public long[][] LONG(int l, char c) { return R(long.Parse, l, c); }
        public double DOUBLE() { return R(double.Parse); }
        public double[] DOUBLE(char c) { return R(double.Parse, c); }
        public double[] DOUBLE(int l) { return R(double.Parse, l); }
        public double[][] DOUBLE(int l, char c) { return R(double.Parse, l, c); }
        public void WRITE(string s, bool lf = true) { W(v => v, s, lf); }
        public void WRITE(int s, bool lf = true) { W(v => v.ToString(), s, lf); }
        public void WRITE(long s, bool lf = true) { W(v => v.ToString(), s, lf); }
        public void WRITE(double s, bool lf = true) { W(v => v.ToString(), s, lf); }
        public void FLUSH() { Console.Write(S); S.Length = 0; }
    }
}

Measured memory_bytes: 10636
n = gets.to_i

min = gets.to_i
dif = gets.to_i - min
min = min + dif if dif < 0

3.upto n do
  input = gets.to_i
  if input < min
    min = input
  elsif min <= input && dif < input - min
    dif = input - min
  end
end

puts dif



Measured memory_bytes: 6864
import java.lang.reflect.Array;
import java.util.*;
import java.io.*;
import java.lang.*;

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

        String s = sc.next();

        if (s.contains("7"))
            System.out.println("Yes");
        else
            System.out.println("No");
    }
}


Measured memory_bytes: 35660
#include <iostream>

int main() {
  std::string s;
  std::cin >> s;
  unsigned cnt_a = 0;
  unsigned cnt_b = 0;
  unsigned cnt_c = 0;
  for (auto &i : s) {
    if (i == 'a') {
      ++cnt_a;
    } else if (i == 'b') {
      ++cnt_b;
    } else if (i == 'c') {
      ++cnt_c;
    }
  }
  auto max = std::max(cnt_a, std::max(cnt_b, cnt_c));
  if (cnt_a + 1 >= max && cnt_b + 1 >= max && cnt_c + 1 >= max) {
    std::cout << "YES" << std::endl;
  } else {
    std::cout << "NO" << std::endl;
  }
  return 0;
}

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

void solve(long long A, long long B){
	
	int ans = 0;

	for(long long n = A; n <= B; n++)
	{
		string num = to_string(n);

		if (num.c_str()[0] != num.c_str()[4]) continue;
		if (num.c_str()[1] != num.c_str()[3]) continue;
		ans++;
	}
		
	cout << ans << endl;
}

int main(){	
	long long A;
	long long B;
	scanf("%lld",&A);
	scanf("%lld",&B);
	solve(A, B);
	return 0;
}



Measured memory_bytes: 256
def f(n,m):
     a = list(map(int,input().split()))
     min_a = min(a)
     a = [(1,i) for i in a]
     b_c = [tuple(map(int,input().split())) for i in range(m)]
     a += b_c
     a.sort(key=lambda x:x[1])
     ans = 0
     while True:
          if n>a[-1][0]:
               ans += a[-1][0]*a[-1][1]
               n -= a[-1][0]
               a.pop()
          else:
               ans += a[-1][1]*n
               break
     print(ans)

n,m = map(int,input().split())
f(n,m)

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define rep(i, n) REP(i, 0, n)
const ll INF=1e9;
const ll MAX=100005;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

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

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a,b,x;
    cout<<std::setprecision(10);
    cin>>a>>b>>x;

    double ans=0;
    if(a*a*b/2>=x){
        double tan = 2.0*x/b/b/a;
        double unit_r = 180.0 / M_PI;
        ans = atan(tan)*unit_r;
    }else{
        double tan = a*a*a/(2.0*(1.0*a*a*b-x));
        double unit_r = 180.0 / M_PI;
        ans = atan(tan)*unit_r;
    }
    cout<<90-ans<<endl;
    return  0;
}


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

  #define vi vector<int>
  #define all(v) v.begin(),v.end()
  #define ll long long int
  #define  IOS    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
  #define D1(x) {cerr<<" [" <<#x<<": "<<x<<"]";cout << endl;}
  #define D2(x) {cerr<<" [" <<#x<<": ";for(auto it:x)cerr<<it<< " ";cerr<<"] ";cout << endl;}

  const ll MOD=1e9+7;

  void solve(){
     string s;
     cin >> s;
     int n =s.size();
     int k = s.find('A');
     reverse(all(s));
     int i = s.find('Z');
     cout << (n-(i+k));
  }


  int main(){
    IOS
       solve();
  }
// integer overflow
// remember to clear visited array
// take input as vector<string> while using grid
// don't assign after modifying


Measured memory_bytes: 720
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <cstring>
#include <climits>
#include <string.h>
#include <stdio.h>
#define LL long long
#define all(x) (x).begin(),(x).end()
#define pii pair<int,int>
#define piii pair<int, pii >
#define REP(i,n) for (int (i)=0;(i)<(n);(i)++)
#define vi vector<int>
#define vpi vector< pii >
#define INF 2147483647
#define big 19260817
#define pb push_back
#define mp make_pair
using namespace std;
const int Maxk=1005;
string mul(string a,string b){
	int res[Maxk];
	memset(res,0,sizeof(res));
	reverse(a.begin(),a.end());
	reverse(b.begin(),b.end());
	for (int i=0;i<a.length();i++){
		for (int j=0;j<b.length();j++){
			res[i+j]+=(a[i]-'0')*(b[j]-'0');
		}
	}
	for (int i=0;i<Maxk;i++){
		if (res[i]>=10) {
			res[i+1]+=(res[i]/10);
			res[i]%=10;
		}
	}
	string ret;
	bool flag=false;
	for (int i=Maxk-1;i>=0;i--){
		if (flag || res[i]){
			flag=true;
			ret=ret+(char)(res[i]+'0');
		}
	}
	if (ret=="") ret="0";
	return ret;
}
string add(string a,string b){
	if (a.length()<b.length()) swap(a,b);
	while (a.length()!=b.length()){
		b='0'+b;
	}
	for (int i=a.length()-1;i>=0;i--){
		a[i]+=(b[i]-'0');
		if (a[i]>'9' && i){
			a[i]-=10;
			a[i-1]++;
		}
	}
	if (a[0]>'9'){
		a[0]-=10;
		a='1'+a;
	}
	return a;
}
// cf IO: I64d
// atcoder IO: ｌｌ
const int Maxn=200005;
int a[Maxn];
long long sum[Maxn];
LL mabs(LL x){
	if (x<0LL) return -x;
	return x;
}
int main(){
	int n;
	scanf("%d",&n);
	for (int i=1;i<=n;i++){
		scanf("%d",&a[i]);
	}
	for (int i=1;i<=n;i++){
		sum[i]=sum[i-1]+(LL)a[i];
	}
	long long ans=1e18;
	for (int i=1;i<n;i++){
		ans=min(ans,mabs(sum[n]-sum[i]-sum[i]));
	}
	printf("%lld\n",ans);
	return 0;
}

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

int n=0;
bool flag[20]={false};
//int table[1048576][156];
/*
int trans(){
  int cnt=0;
  for(int i=n-1;i>=0;i--){
    cnt+=flag[i];
    cnt=(cnt<<1);
  }
  return cnt;
}
*/
int solve(int sum,int k,int start){
  //int c=trans();
  if(k==0 && sum==0) return 1;
  if(sum <= 0) return 0;
  if(k<=0) return 0;
  // if(table[c][sum]!=-1) return table[c][sum];
  int cnt=0;
  for(int i=start;i>=0;i--){
    if(!flag[i]){
      flag[i]=true;
      cnt+=solve(sum-i-1,k-1,i-1);
      flag[i]=false;
    }
  }
  //  if(c < 1024)
  //   return (table[c][sum]=cnt);
    // else return cnt;
  return cnt;
}

int main(){
  int k,s;
  while(cin>>n>>k>>s,n){
    //  memset(table,-1,sizeof(table));
    for(int i=0;i<20;i++)
      flag[i]=false;
    cout<<solve(s,k,n-1)<<endl;
  }
  return 0;
}

Measured memory_bytes: 1160
H, W, K = map(int, input().split())
c = [input() for _ in range(H)]
# print(c)
ans = 0
for bi in range(1<<H):
    for bj in range(1<<W):
        cnt = 0
        for i in range(H):
            if (bi>>i)&1: continue
            for j in range(W):
                if (bj>>j)&1: continue
                if c[i][j]=='#':
                    cnt += 1
        if cnt==K:
            ans += 1
print(ans)

Measured memory_bytes: 9112
#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;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
/*
    s.find_by_order(k) ---> returns iterator to the element at index(from 0) k
    s.order_of_key(val) ---> number of elements that are strictly smaller than the given value
*/
typedef long long int ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<long long int> vl;
typedef vector<vector<int>> vvi;
typedef vector<vector<long long int>> vvl;
typedef pair<int, int> pii;
typedef pair<long long int, long long int> pll;
typedef vector<pair<int, int>> vii;
typedef vector<pair<long long int, long long int>> vll;
#define fastIO() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define test() long long int tc; cin >> tc; cin.ignore(); while(tc--) 
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define MOD 1000000007
#define SMOD 998244353
#define HASH 18014398241046527
#define pq priority_queue
#define all(x) x.begin(),x.end()
#define SP(x) setprecision(x)
#define sp " "
#define inp(a) ll a;cin>>a;cin.ignore()
#define inps(a,b) ll a,b;cin>>a>>b;cin.ignore()
#define out(a) cout<<SP(20)<<a<<'\n'
#define outs(a,b) cout<<SP(20)<<a<<" "<<b<<'\n'
#define ins insert
#define er erase
#define lb lower_bound
#define ub upper_bound
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
#define inpa(a,n) ll a[n]; for(int i=0; i<n; i++){cin>>a[i];}
#define inpv(a,n) vl a; for(int i=0; i<n; i++){inp(x);a.pb(x);}
#define outa(a,n) for(int i=0;i<n;i++){cout<<a[i]<<" ";}cout<<'\n';
#define outv(v) for(auto i:v){cout<<i<<" ";}cout<<'\n';
set<char> vow = {'a','e','i','o','u','A','E','I','O','U'};
ll xpow(ll n, ll m){if(m==0){return 1;}else{ll x = xpow(n, m/2);if(m&1){return x*x*n;}else{return x*x;}}}
ll xmod(ll a, ll m){return (((a%m)+m)%m);}
ll xmodpow(ll n, ll m, ll y){if(m==0){return 1;}else{ll x = xmodpow(n, m/2, y);if(m&1){return xmod((xmod((xmod(x,y)*xmod(x,y)),y)*xmod(n,y)),y);}else{return xmod((xmod(x,y)*xmod(x,y)),y);}}}
template <typename T>
ll SIZEOF(T a){return (ll)a.size();}

ll dx[] = {1, 0, -1, 0};
ll dy[] = {0, 1, 0, -1};


void SOLVE(){
    ll n;
    cin >> n;
    vl v;
    string s = "";
    while(n){
        ll z = n%26;
        n/=26;
        v.pb(z);
        if(z==0){
            n--;
        }
    }
    for(auto i:v){
        if(i==0){
            s += 'z';
        }
        else{
            s += ('a'+(i-1));
        }
    }
    reverse(all(s));
    cout << s << '\n';
}

int main() {
	fastIO();
	// #ifndef ONLINE_JUDGE
    //     freopen("i.txt", "r", stdin);
    //     freopen("o.txt", "w", stdout);
	// #endif

    ll TC = 1;
    // cin >> TC;
    for(ll tc1=1; tc1<=TC; tc1++){
        // cout << "Case #" << tc1 << ": ";
        SOLVE();
    }
    printclock;
}

Measured memory_bytes: 3828
import sys
input = sys.stdin.readline

def main():
    H, W = map(int, input().split())
    maze = [list(input().rstrip()) for _ in range(H)]
    dp = [[0] * W for _ in range(H)]
    dp[0][0] = 1
    for i in range(H):
        for j in range(W):
            if maze[i][j] == "#":
                continue
            if i + 1 < H: dp[i+1][j] += dp[i][j]
            if j + 1 < W: dp[i][j+1] += dp[i][j]
    print(dp[H-1][W-1] % (10**9+7))

if __name__ == '__main__':
    main()

Measured memory_bytes: 253788
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

public class Main {

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

        InputStreamReader is = new InputStreamReader(System.in);
        BufferedReader reader = new BufferedReader(is);

        List<String> mylist = new ArrayList<>();

        // 標準入力からの値を変数strinputに代入
        String strinput = reader.readLine();

        while (strinput != null) {

            mylist.add(strinput);
            strinput = reader.readLine();

        }

        String s = mylist.get(0);
        StringBuilder sb = new StringBuilder();
        StringBuilder s1 = new StringBuilder();
        StringBuilder s2 = new StringBuilder();

        sb.append(s);
        s1.append(s.substring(0, s.length() / 2));
        s2.append(s.substring((s.length() / 2) + 1, s.length()));

        //        System.out.println(s1 + " " + s2 + " " + s1.equals(s2));

        Boolean chkflg = false;
        if (s.substring(0, s.length() / 2).equals(s.substring((s.length() / 2) + 1, s.length()))) {
            if (s1.equals(s1.reverse())) {
                chkflg = true;
            }
        }

        System.out.println(chkflg ? "Yes" : "No");
    }

}


Measured memory_bytes: 24276
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int m = sc.nextInt();
    long[] x = new long[m];
    for(int i = 0;i<m;i++){
      x[i] = sc.nextLong();
    }
    if(n>=m){
      System.out.println(0);
      return;
    }
    Arrays.sort(x);
    long[] dis = new long[m-1];
    long total = 0l;
    for(int i = 0;i<m-1;i++){
      dis[i] = x[i+1] - x[i];
      total += dis[i];
    }
    Arrays.sort(dis);
    for(int i = 0;i<n-1;i++){
      total -= dis[m-2-i];
    }
    System.out.println(total);

  }
}


Measured memory_bytes: 60624
#include <iostream>
#include <string>
#include <vector>

using namespace std;



int main(){


	long long int x;
	long long int y;
	long long int a;

	long long int cnt;
	cin >> x>> y;

	a = x;

	for(cnt=0;a<=y;cnt++){
		a *= 2;
	}

	cout<<cnt<<endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  cin >> a >> b;
  if(a % 2 == 0 && b % 2 == 0){
    int x = (a + b) / 2;
    cin >> x;
    cout << x << endl;
  }
  else if(a % 2 == 1 && b % 2 == 1){
    int x = (a + b) / 2;
    cin >> x;
    cout << x << endl;
  }
  else{
    int x = 0.5 +(a + b) * 0.5;
    cin >> x;
    cout << x << endl;
  }
 
}


Measured memory_bytes: 3584
#include<bits/stdc++.h>
#include<string>
using namespace std;
int main()
{
    long long int t,n,a,b,x,y,m,i,j,k,l,cnt,flag,sum,flag1;
    cin>>n>>m;
    long long int arr[m+5];
    sum=0;
    for(i=0;i<m;i++)
    {
        cin>>arr[i];
       sum=sum+arr[i];
    }
    if(sum>n)
    {
        cout<<"-1"<<endl;
    }
    else
    {
        cout<<(n-sum)<<endl;
    }
    return 0;
}



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

using ull = unsigned long long;
using ll = long long;
using ld = long double;

const int mod = 1e9 + 7;
const int inf = INT_MAX;

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

    int n;
    cin >> n;

    vector<int> div(n + 1);
    for (int i = 1; i <= n; i++) {
        for (int j = i; j <= n; j += i) {
            div[j]++;
        }
    }

    cout << accumulate(div.begin(), div.end() - 1, 0ll) << '\n';
    return 0;
}

Measured memory_bytes: 7116
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cstdint>
#include <cassert>
#include <random>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T iabs(const T& x) { return max(x, -x); }
// #define abs gabs

i64 dp[10001];
int main() {
    i64 h, n;
    cin >> h >> n;
    vector<i64> a(n + 1);
    vector<i64> b(n + 1);
    for (int i = 1; i <= n; ++i) {
        cin >> a[i] >> b[i];
    }

    for (int j = 1; j <= h; ++j) {
        dp[j] = 1ll << 50;
    }
    for (int i = 1; i <= n; ++i) {
        for (int j = 0; j <= h; ++j) {
            dp[j] = min((j - a[i] > 0 ? dp[j - a[i]] : 0) + b[i], dp[j]);
        }
    }
    cout << dp[h] << endl;
    return 0;
}


Measured memory_bytes: 384
n = int(input())
A = [0]*(n+1)
 
for x in range(1,101):
    for y in range(1,101):
        for z in range(1,101):
            a = x**2+y**2+z**2+x*y+y*z+z*x
            if a <= n:
                A[a] += 1
                
for i in range(n):
    print(A[i+1])
        

Measured memory_bytes: 9256
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main(){
    int n, t;
    cin >> n >> t;
    vector<pair<int, int>> v(n);
    rep(i, n) {
        int c, t;
        cin >> c >> t;
        v[i] = {c,t};
    }
    sort(v.begin(), v.end());
    rep(i, n) {
        if ( v[i].second <= t ) {
            cout << v[i].first << endl;
            return 0;
        }
    }
    cout << "TLE" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int page(int n)
{
  int x;
  if(n%2==0)
  {
    x=n/2;
    return x;
  }
  else
  {
    x=(n/2)+1;
    return x;
  }
}
int main()
{
  int n,res;
  cin>>n;
  res=page(n);
  cout<<res;
  return 0;
}

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

int p[600010],n,m;
char s[200010];

inline int rd()
{
	int x=0;char ch=getchar();
	for (;ch<'0'||ch>'9';ch=getchar());
	for (;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
	return x;
}

inline void print(int x)
{
	static char s[233];
	if (!x) { putchar('0');putchar(' ');return; }
	int tot=0;
	for (;x;x/=10) s[++tot]=x%10+'0';
	for (;tot;tot--) putchar(s[tot]);
	putchar(' ');
}

int ch[10000010][3],id[10000010],tot=1;
bool tag[10000010];

inline void pushdown(const int &o)
{
	if (!tag[o]) return;
	swap(ch[o][1],ch[o][2]);
	tag[ch[o][0]]^=1;tag[ch[o][1]]^=1;tag[ch[o][2]]^=1;
	tag[o]=false;
}

inline void work()
{
	int now=1;
	for (int i=1;i<=m;i++)
	{
		pushdown(now);
		int h0=ch[now][0],h1=ch[now][1],h2=ch[now][2];
		ch[now][0]=h2;ch[now][1]=h0;ch[now][2]=h1;
		now=ch[now][0];
	}
}

int main()
{
	m=rd();n=1;
	for (int i=1;i<=m;i++) n*=3;
	for (int i=0;i<n;i++)
	{
		int now=1,x=i;
		for (int j=1;j<=m;j++)
		{
			int hh=x%3;x/=3;
			if (!ch[now][hh]) ch[now][hh]=++tot;
			now=ch[now][hh];
		}
		id[now]=i;
	}
	scanf("%s",s+1);
	int len=strlen(s+1);
	for (int i=1;i<=len;i++)
	{
		if (s[i]=='S') tag[1]^=1;
		else work();
	}
	for (int i=0;i<n;i++)
	{
		int now=1,x=i;
		for (int j=1;j<=m;j++) pushdown(now),now=ch[now][x%3],x/=3;
		p[id[now]]=i;
	}
	for (int i=0;i<n;i++) print(p[i]);
	putchar('\n');
	return 0;
}

Measured memory_bytes: 15384
# include <iostream>
using namespace std;
int main(void){
  int N;
  int num[110];
  int count, ans = 0;
  
  string S;
  cin >> N;
  cin >> S;
  
  for (int i = 0; i <N; i++){
    char c = S[i];
    if (c == 'I') count+= 1;
    if (c == 'D') count-=1;
   	ans = max(ans, count);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
n = int(input())
t, a = map(int, input().split())
h_list = list(map(int, input().split()))
min = 10 ** 10
nearest = 0

for i in range(1, n+1):
    temp = t - h_list[i - 1]*0.006
    if abs(a - temp) < min:
        min = abs(a - temp)
        nearest = i

print(nearest)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
/*    .___.
     /     \
    | O _ O |
    /  \_/  \
  .' /     \ `.
 / _|       |_ \
(_/ |       | \_)
    \       /
   __\_>-<_/__
   ~;/     \;~     */

#define ll long long
#define s(x) scanf("%lld",&x)
#define s1(x,y) scanf("%lld %lld",&x,&y)
int dx[]= {-1,-1,1,1,0,0,-1,1};
int dy[]= {1,-1,-1,1,-1,1,0,0};
int fx[]= {1,-1,0,0};
int fy[]= {0,0,1,-1};
ll mod = 1000000000+7;
int main()
{
    //freopen("output.txt","w",stdout);
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll a,b,c;
    cin>>a>>b;
    if(a==b)
        cout<<"Draw"<<endl;
    else if(a==1)
        cout<<"Alice"<<endl;
    else if(b==1)
        cout<<"Bob"<<endl;
    else if(a>b)
        cout<<"Alice"<<endl;
    
    else
        cout<<"Bob"<<endl;
    return 0;
}


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

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 
using vs = vector<string>;
using vvs = vector<vs>; 
using vc = vector<char>;
using vvc = vector<vc>; 
using vb = vector<bool>;
using vvb = vector<vb>; 

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const long long INF = 1LL << 60;
typedef pair<int, int> PR;

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define fr(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}
ll keta(ll x){
  ll n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;//繰り返し二乗法
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
ll kaijo(ll x){
  ll z=1;
  if(x==0){
    return 1;
  }
  while(x>0){
    z *=x;
    z %=MOD;
    x--;
  }
  return z;
}
ll yakusu_num(ll n){
  vl yakusu(n+1,1);
  for(ll i=2;i*i<=n;i++){ 
    while(n%i==0){
      n /=i;
      yakusu[i]++;
    }
  }
  if(n!=1)yakusu[n]++;
  ll num=1;
  for(ll i=0;i <=n;i++){
    num*=yakusu[i];
  }
  return num;
}
 

//cout<<""<<endl;
int main(){
  ll S;cin>>S;
  ll nmax=S/3;
  ll ans=0;
  ll w=1000000007;
  //iは項数
  vl kai(2001);
  kai[0]=1;
  ll aaa=1;
  for(ll i=1;i<=2000;i++){
    aaa *=i;
    aaa%=w;
    kai[i]=aaa;
  } 
  for(ll i=1;i<=nmax;i++){
    ll cnt=1;
    ll x=S-3*i;
    ll v = modpow(kai[x],w-2,w);
    ll u = modpow(kai[i-1],w-2,w);
    cnt*=kai[i+x-1];
    cnt%=w;
    cnt *=v;
    cnt%=w;
    cnt *=u;
    cnt%=w;
    ans+=cnt;
    ans%=w;
  }
  cout<<ans<<endl;
}






Measured memory_bytes: 3692