akhauriyash/Code-Regression huggingface dataset:
/*
 * atcoder/abc125_2nd/d.cpp
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> ostream & operator << (ostream & out, vector<T> const & v) {
  for (auto &&a: v) out << a << " "; out << endl; return out;
}
template <class T> void dump(T &a) { cout << a << endl; }
template <class T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template <class T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }

/*
 * i)   0の数が1以上ならすべてプラスで加算.
 * ii)  0が0個なら、負の数が偶数個ならすべてプラスで加算.
 * iii)             奇数個なら絶対値の最小のもの1つのみを残してプラスにして加算. 最小のものを減算.
 */
int N;
void solve() {
  cin >> N;
  bool zero = false;
  int minus = false;
  ll minabs = 10000000000000;
  ll total = 0;
  ll a;
  loop(n,0,N) {
    cin >> a;
    total += abs(a);
    zero |= a == 0;
    minus += a < 0;
    chmin(minabs, abs(a));
  }
  minus %= 2;
  if (!zero and minus) total -= 2 * minabs;
  cout << total << endl;
}
int main() {
  // cout.precision(15); cout << fixed;

  solve();

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
  int n,i;
  double sum=0;
  double s[100];
  char t[3][100];
  scanf("%d",&n);
  
  for(i=0;i<n;i++){
   scanf("%lf %s",&s[i],t[i]);
  }
 
  for(i=0;i<n;i++){
    if(t[i][0]=='J'){
      sum=sum+s[i];
    }
    else if (t[i][0]=='B') {
      sum=sum+s[i]*380000.0;
    }
  }
  
  printf("%lf",sum);
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
using namespace std;
void ABC110(void);
void ABC111(void);
void ABC112(void);
void ABC113(void);
void ABC114(void);
void ABC115(void);
void ABC116(void);
void ABC117(void);
void ABC118(void);
void ABC119(void);

int main(void){
    ABC114();
}

void ABC114(){
    int x;
    cin>>x;
    if(x==3||x==5||x==7)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}

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

int youbi(string S) {
    if (S == "SUN") return 0;
    else if (S == "MON") return 1;
    else if (S == "TUE") return 2;
    else if (S == "WED") return 3;
    else if (S == "THU") return 4;
    else if (S == "FRI") return 5;
    else if (S == "SAT") return 6;
    else return -1;
}

int main(){ 
    string S;
    cin >> S;
    cout << 7 - youbi(S) << endl;
    
}




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

int main(){
  ll n;
  while(cin>>n,n){
    bool a[50][30]={};
    ll g[50]={};
    ll m;
    for(ll i=0;i<n;i++){
      cin>>m;
      for(ll j=0,x;j<m;j++){
	cin>>x,x--;
	a[i][x]=1;
	g[x]|=1LL<<i;
      }
    }

    ll ans=-1,f=1,c[50]={};
    
    for(ll i=0;i<30&&f;i++)

      for(ll j=0;j<n;j++){
	if(a[j][i])
	  for(ll k=0;k<n;k++)
	    if(a[k][i])c[j]|=c[k]|g[i];

	if(c[j]+1==(1LL<<n))f=0,ans=i+1;
      }
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 3044
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll inf = numeric_limits<ll>::max()/3;
const ll mod = 1e9 + 7;

int main(void){
  int n,k;
  string s;
  cin >> n >> k;
  cin >> s;
  int d = s[k-1] - 'A';
  s[k-1] = 'a' + d;
  cout << s << endl;
  return 0;
}


Measured memory_bytes: 256
n,k = map(int,input().split())
a = [0]+list(map(int,input().split()))
t = [0]*(n+1)
l = [1]
t[1] = 1
x = 1
y = 0
for i in range(n):
    if(t[a[x]] == 0):
        x = a[x]
        t[x] = 1
        l.append(x)
    else:
        z = i+1
        y = l.index(a[x])
        break
if(k>y):
    print(l[(k-y)%(z-y)+y])
else:
    print(l[k])

Measured memory_bytes: 104204
#include <algorithm>
#include <bits/stdc++.h>
#include <bitset>
#include <cassert>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <cmath>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <vector>
using namespace std;
#define REP(i, n) for (int64_t i = 0; i < (int64_t)n; i++)
#define REP_FOR(i, a, b) for (int64_t i = (int64_t)a; i < (int64_t)b; i++)
#define REP_REV(i, a, b) for (int64_t i = (int64_t)a; i > (int64_t)b; i--)
#define FORALL(v) (v).begin(), (v).end()
#define mp(a, b) make_pair(a, b)
#define eb(x) emplace_back(x)
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int64_t, int64_t> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int64_t> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int64_t infi = 1147483600;
const ll infl = 4e18 + 5;
const char EOL = '\n';
const ll MOD = 998244353;

ll gcd(ll a, ll b) {
    if (b == 0) return a;
    else return gcd(b, a%b);
}


int main() {
    ll a, b;
    cin >> a >> b;
    cout << (a * b) / gcd(a,b) << endl;
}


Measured memory_bytes: 256
import itertools
import math
import statistics
n = int(input())
kyori = [list(map(int, input().split())) for _ in range(n)]

seq = list(itertools.permutations(list(range(n))))

sum_list = []
for s in seq:  #移動の仕方の組み合わせ
    sum = 0
    for i in range(n-1):  # 町の数
        sum += math.sqrt((kyori[s[i]][0]-kyori[s[i+1]][0])**2 + (kyori[s[i]][1]-kyori[s[i+1]][1])**2)
    sum_list.append(sum)

print(statistics.mean(sum_list))

Measured memory_bytes: 12940
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
int head[200005],to[200005],nxt[200005],vis[200005],num,n,ans,u,v;
void add(int u,int v)
{
	nxt[++num]=head[u];
	head[u]=num;
	to[num]=v;
}
int dfs(int now,int deep)
{
	vis[now]=1;
	int nowans=0;
	if(now==n) return deep;
	for(int i=head[now];i;i=nxt[i])
	if(!vis[to[i]])
	{
		nowans=max(dfs(to[i],deep+1),nowans);
	}
	return nowans;
}
void color(int now,int c,int nowdeep,int topdeep)
{
	vis[now]=c;
	if(nowdeep==topdeep)
	{
		return;
	}
	for(int i=head[now];i;i=nxt[i])
	if(!vis[to[i]])
	{
		color(to[i],c,nowdeep+1,topdeep);
	}
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<n;++i)
	{
		scanf("%d%d",&u,&v);
		add(u,v);
		add(v,u);
	}
	int maxdeep=dfs(1,0);
	memset(vis,0,sizeof vis);
	color(1,1,0,maxdeep/2);
	color(n,2,0,n*2);
	for(int i=1;i<=n;++i)
	if(vis[i]==2) ans++;
	if(ans>=(n-ans))
	{
		printf("Snuke");
	}
		else printf("Fennec");
	
	return 0;
}

Measured memory_bytes: 6144
#include <stdio.h>
int main(void){
    int N, i, ans = 0, max = 0;
    int p[10000];
    
    scanf("%d", &N);
    
    for(i = 0; i < N; i++){
        scanf("%d", &p[i]);
    }
    
    for(i = 0; i < N; i++){
        if(max < p[i]){
            max = p[i];
            p[i] = max;
        }
    }
    
    for(i = 0; i < N; i++){
        if(max == p[i]){
            p[i] = p[i] / 2;
            break;
        }
    }
    
    for(i = 0; i < N; i++){
        ans = ans + p[i];
    }
    printf("%d\n", ans);
    
}


Measured memory_bytes: 1716
#include<bits/stdc++.h>
#define ll long long
#define inf 9999999999999999
#define F first
#define S second
#define eb emplace_back
#define mpp make_pair
#define P(x) cout<<__LINE__ <<": "<<#x<<' '<<(x)<<'\n'
#define dbg cout<<__LINE__ <<": 0manush\n"
#define read(x) freopen("input.txt","r",stdin)
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pi 2*acos(0.0)
#define ee exp(1)
#define mx 100009
#define mod 100000007
using namespace std;


int main(){//read(x);
//fast;
ll r,g,h,i,j,t,e,a,b,c,n,l,k,d,f,z=0;
    cin>>a>>b>>c>>d;
    g=max(a*c,a*d);
    h=max(b*c,b*d);
    cout<<max(g,h)<<endl;
}




















Measured memory_bytes: 3584
#include <bits/stdc++.h>
using intl = long long;
using itnl = long long;
using itn = int;
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define rrep(i, n) for(intl i = (intl)(n); i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define rrepi(i, a, b) for(intl i = (intl)(a); i >= (intl)(b); i--)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,1,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define alength(a) (sizeof(a) / sizeof(a[0]))
#define cin(i, a) rep(i, alength(a))cin >> a[i]
#define ccin(i, j, a) rep(i, alength(a))rep(j, alength(a[i]))cin >> a[i][j]
#define debug(x) cout << #x << ":" << x << endl
#define rdebug(i,x) rep(i, alength(x))cout << #x << "[" << i << "]:" << x[i] << endl
#define sqrt sqrtl
#define itn int
#define double ld
#define pb push_back
#define mp make_pair
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld eps = 1.0e-14;//-9
void fp(bool f){cout << (f ? "Yes" : "No") << endl;}
void fp(bool f, string s, string t){cout << (f ? s : t) << endl;}
intl kai(intl k){
    intl a = 1;
    for(int i = 2; i <= k; i++){
        a *= i;
    }
    return a;
}
intl gcd(intl a, intl b){
    if(!b)return a;
    return gcd(b, a % b);
}
intl lcm(intl a,intl b){
    return a / gcd(a, b) * b;
}
intl digit10(intl a){
    intl b = 0;
    do{
        a /= 10;
        b++;
    }while(a);
    return b;
}
signed main(){
    cout << fixed << setprecision(10);
    intl n,m;
    cin >> n >> m;
    fp((n%2)&&(m%2),"Odd","Even");
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <ctype.h>

int main(){
    int y1, m1, d1, y2, m2, d2, i, j;
    int cnt = 0;
    int month[][12] = {{0,31,59,90,120,151,181,212,243,273,304,334}
        ,{0,31,60,91,121,152,182,213,244,274,305,335}};
    while(1){
        cnt = 0;
        scanf("%d %d %d %d %d %d",&y1,&m1,&d1,&y2,&m2,&d2);
        if(y1<0 || m1<0 || d1<0 || y2<0 || m2<0 || d2<0){
            break;
        }
        i = y1 * 365
        + month[ !!( !( y1 % 4 ) && ( ( y1 % 100 ) || !( y1 % 400 ) ) ) ][ m1 - 1 ]
        + d1 + ( ( y1 - 1 ) / 4 ) - ( ( y1 - 1 ) / 100 ) + ( ( y1 - 1 ) / 400 );
        j = y2 * 365
        + month[ !!( !( y2 % 4 ) && ( ( y2 % 100 ) || !( y2 % 400 ) ) ) ][ m2 - 1 ]
        + d2 + ( ( y2 - 1 ) / 4 ) - ( ( y2 - 1 ) / 100 ) + ( ( y2 - 1 ) / 400 );
        printf("%d\n",j - i);
    }
    return 0;
}

Measured memory_bytes: 596
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int m = sc.nextInt();
		
		int total = 0;
		
		for(int i =0; i < m; i++) {
			int num = sc.nextInt();
			total+=num;
		}

		if(n<=total) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
		
		

	}
}


Measured memory_bytes: 48756
#include <iostream>

using namespace std;

int main() {
	int a, b, c, k;
	cin >> a >> b >> c >> k;
	
	while (k--) {
		if (a < b && b < c) {
			cout << "Yes\n";
			return 0;
		} 
		if (b <= a) {
			b *= 2;
			continue;
		}
		if (c <= b) {
			c *= 2;
		}
	}
	
	
    if (a < b && b < c) {
		cout << "Yes\n";
	} 
	else cout << "No\n";
	
	return 0;
}

Measured memory_bytes: 3540
import java.util.Scanner;
//import java.util.ArrayList;
//import java.util.Arrays;
//import java.util.PriorityQueue;
class Main {
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        
        int a = stdIn.nextInt();
        int b = stdIn.nextInt();
        if(a == 1 && b== 1){
            System.out.println(1000000);
        }else {
            int x = 0;
            if(a == 1){
                x += 300000;
            }else if(a == 2){
                x += 200000;
            } else if(a == 3){
                x+= 100000;
            }
            if(b == 1){
                x += 300000;
            }else if(b == 2){
                x += 200000;
            } else if(b == 3){
                x+= 100000;
            }
            System.out.println(x);
        }
        
    }

}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
int main(){int i,j,n;
cin>>n;
long long int dp[n+1][2];
long long a[n+1],k=-1000000009,l=n/2,ans;
ans=k;
memset(dp,k,sizeof(dp));
for(i=1;i<=n;i++)cin>>a[i];
if(n==1){cout<<a[1];return 0;}
if(n==2){cout<<max(a[1],a[2]);return 0;}
if(n==3){cout<<max(a[1],max(a[2],a[3]));return 0;}
dp[1][1]=a[1];
dp[2][1]=a[2];
dp[3][1]=a[1]+a[3];
dp[3][0]=a[3];
dp[4][0]=a[4];
dp[4][1]=a[4]+max(a[1],a[2]);
for(i=5;i<=n;i++){
    k=(i+1)/2;
    if(i%2){dp[i][1]=a[i]+dp[i-2][1];}
    else{dp[i][1]=a[i]+max(dp[i-2][1],dp[i-3][1]);}
    if(i%2){
        dp[i][0]=a[i]+max(dp[i-2][0],max(dp[i-3][1],dp[i-4][1]));
    }else{
        dp[i][0]=a[i]+max(max(dp[i-2][0],dp[i-3][0]),max(dp[i-4][1],dp[i-5][1]));
    }
}
if(n%2==0){ans=max(dp[n][1],dp[n-1][1]);}
else{
    ans=max(dp[n-1][1],dp[n-2][1]);
    ans=max(ans,dp[n][0]);
}
cout<<ans;
    return 0;}

Measured memory_bytes: 8324
#include<bits/stdc++.h>
using namespace std;
int n,A,B;
long long int K;

/*#### modular_arithmetic */
class modular_arithmetic{
public:
	int mod, range;

	modular_arithmetic(){
		mod = 998244353;
	}
	//No specific settings.
	int add(int x,int y){return (x+=y)<mod?x:x-mod;}
	int sub(int x,int y){return (x-=y)>=0?x:x+mod;}
	int mul(int x,int y){return (int)((long long int)x*y%mod);}
	int pw(int base, int p) {
    	int res = 1, mu = base%mod;
    	for(;p>0;p/=2) {
    		if (p&1) res = mul(res, mu);
    		mu = mul(mu, mu);
    	}
    	return res;
    }
    int rev(int x) {return pw(x, mod-2);}
};
/*####*/
modular_arithmetic ma;

int c[303333];
int main(){
	cin >> n >> A >> B >> K;
	c[0] = 1;
	for(int i=1; i<=n; i++){
		c[i] = ma.mul(ma.mul(c[i-1], n+1-i), ma.rev(i));
	}
	int res = 0;
	for(int i=0; i<=n; i++){
		long long int w = K - 1LL * A * i;
		if(w >= 0 && w % B == 0){
			w /= B;
			if(0 <= w && w <= n)
				res = ma.add(res, ma.mul(c[w], c[i]));
		}
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 1408
import java.io.*;
import java.util.*;
public class Main {
    
    public static void main(String[] args) throws IOException {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st=new StringTokenizer(br.readLine());
        int n=Integer.parseInt(st.nextToken());
        int k=Integer.parseInt(st.nextToken());
        System.out.println(k*(int)Math.pow(k-1,n-1));
    }
    
}


Measured memory_bytes: 8276
n = int(input())
a = list(map(int, input().split()))
b = [0 for _ in range(n)]
c = []
for i in range(n-1, -1, -1):
    b[i] = sum(b[i::i+1])%2^a[i]
    if b[i] == 1:
        c.append(i+1)
if c == []:
    print(0)
else:
    print(len(c))
    for i in range(len(c)):
        print(c[i], end=' ')
    print()


Measured memory_bytes: 13112
//#include<bits/stdc++.h>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<stdlib.h>
#include<queue>
#include<map>
#include<vector>
#include<cmath>
#include<fstream>
#include <set>
//freopen(".in","r",stdin);
//freopen(".out","w",stdout);
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
const int  MAXN =3e5+10;
const int mod = 1e9 + 7;
const long long INF = 0x7f7f7f7f7f7f7f7f;
const int inf= 0x3f3f3f3f;
#define eps 1e-8
#define PI 3.1415926535898
#define lowbit(x) (x&(-x))

using namespace std;

char mp[2020][2020];
int dis[2020][2020];
int vis[2020][2020];
int h,w,x11,y11,x2,y2;
int sum=inf;
int dx[4]= {0,0,1,-1};
int dy[4]= {1,-1,0,0};
struct A
{
    int x,y,v;
    //A(int x=0,int y=0,int v=0):x(x),y(y),v(v) {}
    bool operator<(const A&o)const//优先队列的大小比较
    {
        return v>o.v;
    }
};
int main()
{
    cin>>h>>w;
    cin>>x11>>y11;
    cin>>x2>>y2;
    for(int i=1; i<=h; i++)
    {
        for(int j=1; j<=w; j++)
        {
            cin>>mp[i][j];
        }
    }
    memset(dis,inf,sizeof(dis));
    priority_queue<A>q;
    q.push((A){x11,y11,dis[x11][y11]});
    dis[x11][y11]=0;
    while(!q.empty())
    {

        int x=q.top().x;
        int y=q.top().y;
        q.pop();
        if(vis[x][y])
        {
            continue;
        }
        vis[x][y]=1;
        for(int i=0; i<4; i++)
        {
            int xx=x+dx[i];
            int yy=y+dy[i];
            if(xx>=1&&xx<=h&&yy>=1&&yy<=w&&mp[xx][yy]!='#')//没有越界，不是#
            {
                if(dis[xx][yy]>dis[x][y])
                {
                    dis[xx][yy]=dis[x][y];
                    q.push((A){xx,yy,dis[xx][yy]});
                }
            }
        }
        for(int i=-2; i<=2; i++)
        {
            for(int j=-2; j<=2; j++)
            {
                int xx=x+i;
                int yy=y+j;
                if(xx>=1&&xx<=h&&yy>=1&&yy<=w&&mp[xx][yy]!='#')
                {
                    if(dis[xx][yy]>dis[x][y]+1)
                    {
                        dis[xx][yy]=dis[x][y]+1;
                        q.push((A){xx,yy,dis[xx][yy]});
                    }
                }
            }
        }
    }
    if(dis[x2][y2]==inf)
    {
        cout<<-1<<endl;
    }
    else
    {
        cout<<dis[x2][y2]<<endl;
    }
    return 0;
}

Measured memory_bytes: 29364
import sys

N = int(sys.stdin.readline())
S = sys.stdin.readline().strip()

stack = []
for s_i in S:
    if not stack:
        stack.append(s_i)
    elif stack[-1] == "(" and  s_i == ")":
        stack.pop()
    else:
        stack.append(s_i)

# 余っている左、右のカッコの数 
left = 0
right = 0
for s_i in stack:
    if s_i == ")":
        right += 1
    else:
        left += 1

print("(" * right + S + ")" * left)

Measured memory_bytes: 38384
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<list>
#include<bitset>
#include<stack>
#include<memory>
#include<numeric>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/
const llint mod=1000000007 ;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-10;
const long double epsA=1e-4;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(const vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(const vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
llint solve(array<llint,5>in){
	static llint dp[201][201];
	static llint ep[201][201];
	dp[0][0]=1;ep[0][0]=1;
	int h,i=0,j,k,aa=1;
	for(h=1;h<=4;h++){
		aa*=10;
		for(k=1;k<=in[h];k++){
			i++;
			dp[i][0]=dp[i-1][0];
			ep[i][0]=ep[i-1][0];
			dp[i-1][i]=0;ep[i-1][i]=0;
			for(j=1;j<=i;j++){
				dp[i][j]=(dp[i-1][j]+dp[i-1][j-1]*j)%mod;
				ep[i][j]=(ep[i-1][j]+ep[i-1][j-1]*j*aa)%mod;
			}
		}
		//cerr<<"de"<<__LINE__<<endl;
	}
	int n=in[1]+in[2]+in[3]+in[4];
	//cerr<<"n="<<n<<endl;
	llint ue[201]={};
	llint st[201]={};
	for(i=0;i<=n;i++){
		//cerr<<"de"<<__LINE__<<endl;
		for(j=0;j<=i;j++){ue[i]+=dp[i][j];}
		ue[i]%=mod;
		//cerr<<"i="<<i<<"ue="<<ue[i]<<"st="<<st[i]<<endl;
	}
	llint ans=0;
	for(i=0;i<=n;i++){ans+=ue[i]*ep[n][n-i];ans%=mod;}
	//cerr<<"ans="<<ans<<endl;
	return ans;
	
}

int main(void){
	cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);
	
	llint n;cin>>n;
	//桁数、数字
	//何桁目に来ることがどのくらいあるか
	//桁数 1,2,3,4の4パターンしかない
	//自分より上 m枚まである->dpする
	//0はじめ対策 何とかする
	array<llint,5>mai={},suu={};
	bool Oaru=false;
	int h,i,j;
	for(i=0;i<n;i++){
		int a;cin>>a;
		if(a==0){mai[1]++;Oaru=true;}
		int k=1,kk=0;
		while(k<=a){k*=10;kk++;}
		mai[kk]++;suu[kk]+=a;
	}
	llint ans=0;
	for(h=1;h<=4;h++){
		if(mai[h]==0){continue;}
		mai[h]--;
		ans+=solve(mai)*suu[h];
		if(Oaru&&mai[1]>0){
			mai[1]--;
			ans-=solve(mai)*suu[h];
			mai[1]++;
		}
		ans%=mod;
		mai[h]++;
	}
	ans%=mod;ans+=mod;ans%=mod;
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3748
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define re(i,a,b) for(int i=(a);i<(b);i++)
#define repd(i,a,b) for(int i=(a);i>=(b);i--)
#define run(v) for(int k=head[v];k;k=e[k].ne)
#define v e[k].t
#define clr(a) memset(a,0,sizeof(a));
#define il inline
#define sz(a) ((int)a.size())
#define all(a) a.begin(),a.end()
#define mp make_pair
#define pb push_back 
#define w1 first
#define w2 second
#define adm(a,b,c) {a=a+b;if(a>=c)a-=c;else if(a<0)a+=c;}
typedef long long ll;typedef long double ld;typedef unsigned long long ull;
typedef pair<ll,ll> pa;
const int N=5e5+5,M=1e7+5,INF=1e9,mod=1e9+7;
const ll linf=1e18;const double eps=1e-8,pi=acos(-1);
il int gmin(int &a,int b){if(a>b)a=b;}il ll gmin(ll &a,ll b){if(a>b)a=b;}il int gmax(int &a,int b){if(a<b)a=b;}il ll gmax(ll &a,ll b){if(a<b)a=b;}
il void read(ll&x){ll f=1,t=0;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){t=t*10+ch-'0';ch=getchar();}x=t*f;}il ll read(ll&x,ll&y){read(x);read(y);}
il void read(int&x){int f=1,t=0;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){t=t*10+ch-'0';ch=getchar();}x=t*f;}il int read(int&x,int&y){read(x);read(y);}
il void read(int&a,int&b,int&c){read(a);read(b);read(c);}il void read(ll&a,ll&b,ll&c){read(a);read(b);read(c);}
il int read(){int x;read(x);return x;}
il ll qpow(ll a,ll b,ll p){ll ret=1;for(;b;b>>=1,a=a*a%p)if(b&1)ret=ret*a%p;return ret;}il ll qpow(ll a,ll b){ll ret=1;for(;b;b>>=1,a=a*a%mod)if(b&1)ret=ret*a%mod;return ret;}
il ll qmul(ll a,ll b,ll p){ll ret=0;for(;b;b>>=1,a=(a<<1)%p)if(b&1)adm(ret,a,p);return ret;}il ll qmul(ll a,ll b){ll ret=0;for(;b;b>>=1,a=(a<<1)%mod)if(b&1)adm(ret,a,mod);return ret;}
il void judge(){
	freopen("data.in","r",stdin);
	freopen("data.out","w",stdout);}
il void gen(){freopen("data.in","w",stdout);}
int n,m,bit[N];
struct data{int l,r,len;}a[N];
il bool cmp(data a,data b){return a.len<b.len;}
void add(int x,int y){for(;x<=m;x+=x&(-x))bit[x]+=y;}
int sum(int x){int res=0;for(;x;x-=x&(-x))res+=bit[x];return res;}
int main(){
	read(n,m);
	rep(i,1,n)read(a[i].l,a[i].r),a[i].len=a[i].r-a[i].l+1;
	sort(a+1,a+1+n,cmp);
	int pt=1;
	rep(d,1,m){
		while(pt<=n&&a[pt].len<d){
			add(a[pt].l,1);
			add(a[pt].r+1,-1);		
			pt++;
		}
		int ans=n-pt+1;
		for(int cur=d;cur<=m;cur+=d)ans+=sum(cur);
		cout<<ans<<endl;
	}
}

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

using namespace std;

typedef pair<int,int> pii;
typedef long long ll;
typedef vector<int> vi;
#define rep(i, n) for(int i = 0; i < n; ++i)
#define rInt(a) scanf("%d",&a);

ll sieve_size;
bitset<10000010> bs;
vi primes;
void sieve(ll size){
   sieve_size = size + 1;
   bs.set();
   bs[0] = bs[1] = 0;
   for (ll i = 2; i <= sieve_size; i++) if (bs[i]){
       for (ll j = i * i; j <= sieve_size; j += i) bs[j] = 0;
       primes.push_back((int)i);
   }    
}

bool isPrime(ll N){
    return bs[N];
}

main(){
   vi sum (100010,0);
   sieve(1000000);
   rep(i,sum.size()){
       if(i==0) continue;
       sum[i] = sum[i-1];
       if(i%2==1 and isPrime(i) and isPrime((i+1)/2)) sum[i]++;
   }
   int q; rInt(q);
   int a,b;
   //cout << isPrime(3) << endl;
   while(q--){
       scanf("%d %d",&a,&b);
       cout << sum[b] - sum[a-1] << endl;
   }
}

Measured memory_bytes: 2680
#include<iostream>
#include<string>
#include<cstdlib>

#define N 100000
using namespace std;


typedef struct{
  int num[N];
  int head;
  int tail;
}Queque;


//grobal
Queque que;

//add to head position
void Enqueue(int);
//delete head position
void Dequeue(void);
//return now of stck
int front(void);


int main(){
  //format
  que.head=0;
  que.tail=0;

  int pasttime=0;
  int i,n,q,tim=0;
  string name[N];
  int finishcount=0;
  int flag[N];
  int st;

  //load n and q
  cin >>n>>q;

  //load name and time
  for(i=0;i<n;i++){
    cin >>name[i]>>tim;
    Enqueue(tim);
  }

  //format flag
  for(i=0;i<n;i++){
    flag[i]=0;
  }
  
  i=0;

  while(1){
    if(finishcount==n) break;
    //i->n i=0 continue
    else if(i==n){
      i=0;
      continue;
      }
    //flag=1 go next
      else if(flag[i]==1){
      i++;
      continue;
    }
    //load
    st=front();

    if(st>q){
      Enqueue(st-q);
      Dequeue();
      pasttime+=q;
    }

    else{
      Dequeue();
      pasttime+=st;
      flag[i]=1;
      finishcount++;
      //print
      cout <<name[i]<<" "<<pasttime<<endl;
    } 
    
    i++;
  }
    
  
  return 0;
  
}

//add to head position
void Enqueue(int x){
  que.num[que.tail]=x;
  que.tail++;
  //if tail>N tail is 0
  if(que.tail>=N)que.tail=0; 
}
//delete head position
void Dequeue(void){
  que.head++;
  //if head>N head is 0
  if(que.head>=N)que.head=0;
}
//return now of stck
int front(void){
  return que.num[que.head];
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = LONG_LONG_MAX / 2;
const ll mod = 1000000000 + 7;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main() {
  int H, W, K;
  cin >> H >> W >> K;
  vector<vector<ll>> dp(H + 1, vector<ll>(W, 0));
  dp[0][0] = 1;

  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      for (int bit = 0; bit < 1 << (W - 1); bit++) {
        bool is_amida = true;
        for (int k = 0; k < W - 2; k++) {
          if ((bit & (1 << k)) && (bit & (1 << (k + 1)))) is_amida = false;
        }
        if (!is_amida) continue;
        int nj = j;
        if ((bit & (1 << j)))
          nj = j + 1;
        else if (j > 0 && (bit & (1 << (j - 1))))
          nj = j - 1;
        dp[i + 1][nj] += dp[i][j];
        dp[i + 1][nj] %= mod;
      }
    }
  }
  cout << dp[H][K - 1] << endl;
}


Measured memory_bytes: 3612
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<iomanip>
#include <math.h>
using namespace std;

int main(){
    long long int n=0;
    string s,t;
    cin>>s>>t;
    for(int i=0;i<s.size();i++){
        if(s[i]!=t[i]){
            n++;
        }
    }
    cout<<n<<endl;
    
}


Measured memory_bytes: 3812
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>
#include <set>

#define REP(i,a) for(int i = 0;i < (a);++i)
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SIZE(obj) (int)(obj).size()
#define MAX(list) std::max(list)
#define MIN(list) std::min(list)
#define YESNO(cond,yes,no){cout <<((cond)?(yes):(no))<<endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(),(list).rend())

using namespace std;

template<typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

template <typename T1, typename T2>
istream& operator>>(istream& is, pair<T1, T2>& p) {
    is >> p.first >> p.second;
    return is;
}

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

template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
    REP(i, (int)v.size())is >> v[i];
    return is;
}

template <typename T>
ostream& operator<<(ostream& os, vector<T>& v) {
    REP(i, (int)v.size())os << v[i] << endl;
    return os;
}


using ll = long long;
//ll mod = 1'000'000'007;
int mod = 2019;

const int INF = 1'050'000'000;

int clamp(int n, int a, int b) {
    if (n < a)n = a;
    if (n > b)n = b;
    return n;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout << fixed << setprecision(20);

    int L, R;
    cin >> L >> R;

    if (L / mod != R / mod) {
        cout << 0 << endl;
        return 0;
    }
    L %= mod;
    R %= mod;

    int ans = 2018;

    if (L >= R) {
        cout << 0 << endl;
        return 0;
    }

    FOR(i, L, R) {
        FOR(j, i + 1, R + 1) {
            ans = min(ans, (i * j) % mod);
        }
    }
    cout << ans << endl;
    return 0;

}

Measured memory_bytes: 256
//①両端からほどくのが最善. 以降は両端からほどくことを考える。
//②最後にほどくときは、紐が2本つながっている状態。
//最後に紐i, i+1をほどくためには、a[i] + a[i+1] >= Lを満たす必要がある。
//逆にこれを満たしていれば、紐i, i+1を最後にほどくことができ、それ以前の操作は(紐i, i+1を残しながらほどけば)何でもOK.

#include <iostream>
#define int long long
using namespace std;

int n, l;
int a[100000];

signed main() {
	int i;
	
	cin >> n >> l;
	for (i = 0; i < n; i++) { cin >> a[i]; }
	
	for (i = 0; i < n - 1; i++) {
		if (a[i] + a[i+1] >= l) break;
	}
	if (i == n - 1) { cout << "Impossible" << endl; return 0; }
	
	cout << "Possible" << endl;
	
	//a[i], a[i+1]を残しつつ、両端からほどく
	for (int j = 0; j < i; j++) cout << j + 1 << endl;	//a[j], a[j+1]をほどく
	for (int j = n - 2; j >= i + 1; j--) cout << j + 1 << endl;	//a[j], a[j+1]をほどく
	cout << i + 1 << endl;
	return 0;
}

Measured memory_bytes: 1536
N=int(input())
xu=[list(input().split()) for _ in range(N)]
# print(xu)

ans=0
for i in range(N):
	if xu[i][1]=='JPY':
		ans+=float(xu[i][0])
	else:
		ans+=float(xu[i][0])*380000.0
print(ans)

Measured memory_bytes: 3060
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let a: u32=read();
    println!("{}",a+a*a+a*a*a);
}

Measured memory_bytes: 2116
#include <fstream>
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <cmath>

using namespace std;
typedef long long ll;

ll gcd(ll a, ll b) {
    if (a < b) swap(a, b);
    if (b == 0) return a;
    return gcd(b, a % b);
}

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

int main(int argc, const char * argv[]) {
    int N;
    cin >> N;

    vector<ll> T(N);
    for (int i = 0; i < N; i++) cin >> T[i];

    ll lim = (ll)(pow(10, 17) * 5);
    ll tp = T[0];
    for (int i = 1; i < N; i++) {
        if (lim <= max(T[i], tp)) {
            cout << max(T[i], tp) << endl;
            return 0;
        }
        tp = lcm(tp, T[i]);
    }
    cout << tp << endl;

    return 0;
}

Measured memory_bytes: 256
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE BangPatterns #-}

import Control.Applicative
import Control.Monad
import Control.Arrow
import Data.List
import Data.Maybe
import Data.Char
import qualified Data.ByteString.Char8 as B
import Text.Printf

readInt = ( readLn :: IO Int )
readInts = map ( read :: String -> Int ) . words <$> getLine

getList = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

main = do
	[ n, m ] <- readInts
	as :: [Int] <- map read . words <$> getContents
	mapM_ print $ map length $ map ( \x -> filter ( x == ) as ) [ 1 .. n ]


Measured memory_bytes: 1020
#include <iostream>
#include<queue>
#include<stack>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include<cassert>
#include<cmath>
#include<climits>
#include<iomanip>
#include<bitset>
#include<unordered_map>

using namespace std;

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define rep(i,j,n) for(ll (i)=(j);(i)<(n);(i)++)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
typedef pair<ll, ll> P;
const long long INF = 1LL << 60;
const long long MOD = 1e9 + 7;
typedef vector<ll> Array;
typedef vector<Array> Matrix;


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

//グラフ関連
struct Edge {//グラフ
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
		to = _to; cap = _cap; rev = _rev;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

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

ll mod_inv(ll x, ll mod) {
	return mod_pow(x, mod - 2, mod);
}

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

	string c;
	cin >> c;

	cout << (char)(c[0] + 1) << endl;

	return 0;
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

using ll = long long;
using ld = long double;

const ll INF = 1e18;
const int Inf = 1e9;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
    int h1, m1, h2, m2, k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    int time = (h2 - h1) * 60;
    int diff = m2 - m1;
    time += diff;
    cout << time - k << endl;
    
    return 0;
}



Measured memory_bytes: 3652
N = int(input())

xn = [0] * N
yn = [0] * N
hn = [0] * N

for i in range(N):
    xi, yi, hi = map(int, input().split())
    xn[i] = xi
    yn[i] = yi
    hn[i] = hi

div = 0

for Cx in range(101):
    for Cy in range(101):
        for i in range(N):

            if 0 < hn[i]:
                h = abs(xn[i] - Cx) + abs(yn[i] - Cy) + hn[i]
                if div in [0, 2]:
                    H = h
                    div = 1
                else:
                    if (H != h):
                        div = 2
                        break

        if div == 2:
            continue

        for i in range(N):
            if 0 == hn[i]:
                h = abs(xn[i] - Cx) + abs(yn[i] - Cy)
                if h < H:
                    div = 2
                    break

        if div == 2:
            continue

        print(Cx, Cy, H)
        break

    if div == 1:
        break


Measured memory_bytes: 3064
# coding: utf-8

N, T = map(int, input().split())
A = [int(s) for s in input().split()]

cm = A[0]
cd = 0
cnt = 0
for i in range(1, N):
    if A[i] < cm:
        cm = A[i]
    else:
        d = A[i] - cm
        if d == cd:
            cnt += 1
        elif d > cd:
            cd = d
            cnt = 1
print(cnt)


Measured memory_bytes: 14292
#include<stdio.h>

static const int N = 1000;

void trace(int A[], int n){
    int i;
    for ( i = 1; i <= n; i++ ){
    if ( i > 1 ) printf(" ");
    printf("%d", A[i]);
    }
    printf("\n");
}

int main(){
    int n, i, j;
    int key;
    int A[N+1];
    scanf("%d", &n);

    for ( i = 1; i <= n; i++ ) scanf("%d", &A[i]);
  
    /* trace(A, n); */
    for(i=1; i<n+1; i++){
        key = A[i];
        j = i - 1;
        while(j >= 0 && A[j]>key){
            A[j+1] = A[j];
            j--;
        }
        A[j+1] = key;
        trace(A, n);
    }
    return 0;
}

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

#define pb push_back
#define PQ priority_queue
#define make_unique(x) sort((x).begin(), (x).end()); (x).erase(unique((x).begin(), (x).end()), (x).end())

typedef long long ll;
typedef long double ld;

//__builtin_popcount(x)

using namespace std;

/*const int mod = 1e9 + 7;

ll add(ll a, ll b) {
    ll res = a + b;
    if (res >= mod) res -= mod;
    return res;
}

ll sub(ll a, ll b) {
    ll res = a - b + mod;
    if (res >= mod) res -= mod;
    return res;
}

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

int powm(int a, long long n) {
	if (n == 0) {
		return 1;
	}
	else if (n & 1) {
		return mul(a, powm(a, n - 1));
	}
	else {
		return powm(mul(a, a), n / 2);
	}
}*/

/* Z-FUNCTION
ll l = 0, r = 0, n = (int)s.size();
vector<int> z(n, 0);
for (int i = 1; i < n; i++) {
    if (r >= i) {
        z[i] = min(1ll*z[i-l], r-i+1);
    }
    while (z[i] + i < n && s[z[i]] == s[z[i] + i]) z[i]++;
    if (i + z[i] - 1 > r) l = i, r = i + z[i] - 1;
}
*/

/*vector<ll> find_dividers(ll x) {
    vector<ll> dividers;

    for (ll i = 1; i <= sqrt(x); i++) {
        if (x % i == 0) {
           dividers.push_back(i);
            if (1ll*i * i != x) {
                dividers.push_back(1ll*x / 1ll*i);
            }
        }
    }

    return dividers;
}*/

/*int nok(int a, int b) {
    return a / __gcd(a, b) * b;
}*/

// ceil(a/b) = (a+b-1)/b
int n, m;
vector<vector<int>> gr;
vector<bool> used;

void dfs(int u) {
    used[u] = true;
    for (int i = 0; i < (int)gr[u].size(); i++) {
        if (!used[gr[u][i]]) {
            dfs(gr[u][i]);
        }
    }
}

void solve() {
    cin >> n >> m;
    gr = vector<vector<int>>(n + 1);
    used.resize(n + 1);
    for (int i = 0; i < m; i++) {
        int x, y;
        cin >> x >> y;
        gr[x].pb(y);
        gr[y].pb(x);
    }

    int comp = 0;
    for (int i = 1; i <= n; i++) {
        if (!used[i]) {
            comp++;
            dfs(i);
        }
    }
    cout << comp-1 << endl;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //cout.setf(ios::fixed);
    //cout.precision(10);

    int t=1;
    //cin >> t;
    while (t--) {
        solve();
    }

    return 0;
}


Measured memory_bytes: 9468
#include "bits/stdc++.h"
#include "math.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define SIZE(a) int((a).size())
#define out(a) cout<<(a)<<endl;
const int INF=INT_MAX;
const int MAX = 510000;
const int MOD = 1000000007;
ll factorize(ll n) {
    vector<pair<ll,int> > res;
    ll ans=1;
    for (ll i = 2; i * i <= n; i++) {
        if (n % i != 0) continue;
        res.emplace_back(i,0);
        while (n % i == 0) {
            n /= i;
            res.back().second++;
        } 
        ans*=(res.back().second+1);

    }
    if (n != 1) {res.emplace_back(n,1);ans*=2;}
    return ans;
}
int main(){
  ll n,ans=0;cin>>n;
  for(ll i=1;i<=n;i+=2){
    if(factorize(i)==8){ans++;}
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll    long long
#define pb          push_back
#define F first
#define S second
#define    endl        '\n'
#define all(v) (v).begin(), (v).end()
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v)
{
    os << '{';
    string sep;
    for (const auto &x : v) os << sep << x, sep = ", ";
    return os << '}';
}
template<typename T, size_t size> ostream &operator<<(ostream &os, const array<T, size> &arr)
{
    os << '{';
    string sep;
    for (const auto &x : arr) os << sep << x, sep = ", ";
    return os << '}';
}
template<typename A, typename B> ostream &operator<<(ostream &os, const pair<A, B> &p)
{
    return os   << '(' << p.first << ", " << p.second << ')';
}
void dbg_out()
{
    cerr << endl;
}
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T)
{
    cerr << ' ' << H;
    dbg_out(T...);
}

#ifdef LOCAL
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
#else
#define dbg(...)
#endif
const int N = 1e5 + 5;

void solve()
{
    ll d,s,t;
    cin>>d>>s>>t;
    cout<<(d<=t*s?"Yes\n":"No");


}
int main()
{

#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);


    ll TESTS = 1;
    // cin >> TESTS;
    for(int t = 1; t <= TESTS; t++)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3648
import java.util.*

fun main(args: Array<String>) {
    val (n, m) = readIntegerList()
    val alist = readLongList()
    val queue = PriorityQueue<Long>(alist.size) { a, b ->
        if (a == b) {
            0
        } else if (b - a > 0L) {
            1
        } else {
            -1
        }
    }
    for (i in alist) {
        queue.add(i)
    }

    repeat(m) {
        val max = queue.remove()
        queue.add(max / 2L)
    }
    println(queue.sum())
}


fun readInteger() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntegerList() = readStringList().map(String::toInt)
fun readLongList() = readStringList().map(String::toLong)


Measured memory_bytes: 72144
import sys
from collections import Counter
N=int(sys.stdin.readline().strip())
A=map(int, sys.stdin.readline().split())
Q=int(sys.stdin.readline().strip())

KOSUU=Counter(A)
total=sum(A)
for _ in range(Q):
    b,c=map(int, sys.stdin.readline().split())
    total=total-b*KOSUU[b]+c*KOSUU[b]
    print total
    KOSUU[c]+=KOSUU[b]
    KOSUU[b]=0
    

Measured memory_bytes: 97060
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scanner() string {
	sc.Scan()
	return sc.Text()
}

func intScanner() int {
	n, _ := strconv.Atoi(Scanner())
	return n
}

func floatScanner() float64 {
	n, _ := strconv.ParseFloat(Scanner(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func stringSliceScanner(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scanner()
	}
	return a
}
func intSliceScanner(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = intScanner()
	}
	return a
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}

var mod int

func main() {
	mod = 1000000007
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	a := intScanner()
	s := Scanner()
	if a >= 3200 {
		fmt.Println(s)
	} else {
		fmt.Println("red")
	}
}


Measured memory_bytes: 1772
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <unordered_map>
#include <vector>
#include <string.h>
#include <set>

using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> triple;
typedef double D;

const ll INF = 1e9;
const ll MOD = 1000000007;  // 1e9 + 7

ll powmod(ll x, ll n) { // like pow(x, n)
  ll r = 1;
  while (n) {
    if (n & 1) {
      r = r * x % MOD;
    }
    x = x * x % MOD;
    n >>= 1;
  }
  return r;
}

int gcd(int a, int b) {
  if (a < b) { swap(a, b); }
  if (b == 0) { return a; }
  return gcd(b, a % b);
}

int main(int argc, char** argv) {
  ll A, B;
  cin >> A >> B;

  set<ll> a_candidates;
  a_candidates.insert(1);
  for (ll i = 2; i * i <= A; ++i) { // i is the divisor
    while ((A % i) == 0) {
      a_candidates.insert(i);
      A /= i;
    }
  }
  if (A > 1) {
    a_candidates.insert(A);
  }
  // cout << "a_candidates: " << endl;
  // for (auto x : a_candidates) {
  //   cout << x << endl;
  // }
  set<ll> b_candidates;
  b_candidates.insert(1);
  for (ll i = 2; i * i <= B; ++i) { // i is the divisor
    while ((B % i) == 0) {
      b_candidates.insert(i);
      B /= i;
    }
  }
  if (B > 1) {
    b_candidates.insert(B);
  }
  // cout << "b_candidates: " << endl;
  // for (auto x : b_candidates) {
  //   cout << x << endl;
  // }

  set<ll> candidates;
  for (auto x : a_candidates) {
    if (b_candidates.find(x) != b_candidates.end()) {
      candidates.insert(x);
    }
  }
  // cout << "candidates: " << endl;
  // for (auto x : candidates) {
  //   cout << x << endl;
  // }
  // cout << "answer:" << endl;

  cout << candidates.size() << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int n;
long long a[404], b[404], d[404][404];
int main() {
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i];
    for (int i = 1; i <= n; i++) b[i] = b[i - 1] + a[i];
    for (int i = 1; i < n; i++) {
        for (int j = 1; j + i <= n; j++) {
            d[j][j + i] = 1e18;
            //cout << j << ' ' << j + i << '\n';
            //[j,j+i] -> j,j+1,...,j+i-1
            for (int k = j; k < j + i; k++) {
                d[j][j + i] = min(d[j][j + i], d[j][k] + d[k + 1][j + i]);
            }
            d[j][j + i] += b[j + i] - b[j - 1];
        }
    }
    cout << d[1][n] << '\n';
}

/*
 
 */


Measured memory_bytes: 1536
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
using namespace std;
#define FOR(i,s,e) for(ll i = s; i <= (ll)e; ++i)
#define DEC(i,s,e) for(ll i = s; i >= (ll)e; --i)
#define IAMSPEED ios_base::sync_with_stdio(false); cin.tie(0);
#define db(x) cerr << #x << "=" << x << "\n"
#define db2(x, y) cerr << #x << "=" << x << " , " << #y << "=" << y << "\n"
#define db3(a,b,c) cerr<<#a<<"="<<a<<","<<#b<<"="<<b<<","<<#c<<"="<<c<<"\n"
#define dbv(v) cerr << #v << ":"; for (auto ite : v) cerr << ite << ' '; cerr <<"\n"
#define dbvp(v) cerr << #v << ":"; for (auto ite : v) cerr << "{"  << ite.f << ',' << ite.s << "} "; cerr << "\n"
#define dba(a,ss,ee) cerr << #a << ":"; FOR(ite,ss,ee) cerr << a[ite] << ' '; cerr << "\n"
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define ll long long 
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define f first
#define s second
#define reach cerr << "LINE: " << __LINE__ << "\n";
typedef pair <ll, ll> pi;
typedef tuple<ll,ll,ll> ti3;
string cts(char x) {string t(1,x); return t;}
ll rand(ll a, ll b) { return a + rng() % (b-a+1); }
const int MOD = 1e9 + 7;
const int inf = (int)1e9 + 500;
const long long oo = (ll)1e18 + 500;
template <typename T> void chmax(T& a, T b) { a = max(a, b); }
template <typename T> void chmin(T& a, T b) { a = min(a, b); }
const int MAXN = -1;
#ifndef LOCAL
#define cerr if(0)cout
#endif
set<int> ban;
vector<int> v;
int32_t main() 
{
	IAMSPEED
	int m, n; cin >> m >> n;
	FOR(i,1,n) {
		int x; cin >> x;
		ban.insert(x);
	}
	int ans = inf, res = 0;
	FOR(i,-200,200) {
		if(ban.count(i))continue;
		if((int)abs(i-m) < ans) {
			ans = abs(i-m);
			res = i;
		}
	}
	cout << res;
}


Measured memory_bytes: 3668
package main

import (
	"fmt"
)

func main() {
  var a, b, c int
  fmt.Scanf("%d %d %d", &a, &b, &c)

  cnt := map[int]int{}
  cnt[a]++
  cnt[b]++
  cnt[c]++
  ans := "No"
  
  for _, v := range cnt {
    if v == 2 {
      ans ="Yes"
    }
  }
  fmt.Printf("%s\n", ans)
}

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

typedef long long ll;


int main() {
    ll k; scanf("%lld", &k);
    if (k % 2 == 0) {
        puts("-1");
    } else {
        int f = -1;
        ll ans = 0;
        for (int i = 1; i <= 1e7; i++) {
            ans = ans * 10 + 7;
            ans = ans % k;
            if (ans == 0) {
                f = i;
                break;
            }
        }
        if (f > 0) {
            printf("%d\n", f);
        } else {
            puts("-1");
        }

    }
}

Measured memory_bytes: 3824
gets.chomp
ary = gets.chomp.split(" ").map(&:to_i).sort.reverse

val = 0
ary.each_with_index do |e, i|
  #puts "#{i}, #{e}"
  if i.even?
    val += e
  else
    val -= e
  end
end

print "#{val}\n"

Measured memory_bytes: 1788
import sys
def inpl(): return list(map(int, sys.stdin.readline().split()))
n = int(sys.stdin.readline())
a = inpl()
dic ={}
res = 0
for i in range(n):
    res += dic.get(i - a[i], 0)
    dic[i + a[i]] = dic.get(i + a[i], 0) + 1

print(res)

Measured memory_bytes: 39984