akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <cmath>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF=1001001001;
vector<pair<int64_t,int64_t>>func(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p;
}

int main(){
  int64_t A;
  string B;
  cin>>A>>B;
  B=B.erase(1,1);
  int b=stoi(B);
  cout<<A*b/100<<endl;
  return 0;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
typedef pair<int, int> P_i;
typedef pair<double,double> P_d;
#define SZ(x) ((int)(x).size())
#define rep(i,n) for(int i=0;i<(n);++i)
#define alrep(i,j,n) for(int i=0;i<(n);++i)for(int j=i+1;j<(n);++j)
#define Yes cout << "Yes" << endl;
#define No cout << "No" << endl;int ans=0;
#define answer cout << ans << endl;
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; }
template<class T> using v = vector<T>;
template<class T> using vv = vector<vector<T>>;
const int MOD=1e9+7;
const long long INF = 1LL << 60;

int rec(int l,int r,vv<int> &dp,v<int> &w){
  if(dp[l][r]!=-1) return dp[l][r];
  if(abs(l-r)<=1) return 0;
  int res=-1;
  if(abs(w[l]-w[r-1])<=1 && rec(l+1,r-1,dp,w)==r-l-2) res=r-l;
  for(int mid=l+1;mid<=r-1;mid++){
    chmax(res,rec(l,mid,dp,w)+rec(mid,r,dp,w));
  }
  return dp[l][r]=res;
}

signed main(){
  int n;
  while(cin >> n && n!=0){
    vv<int> dp(310,v<int>(310,-1));
    v<int> w(n,0);
    rep(i,n) cin >> w[i];
    cout << rec(0,n,dp,w) << endl;
  }
  return 0;
}



Measured memory_bytes: 3608
#include <bits/stdc++.h>
        using namespace std;
   #define int long long
const int MAX = 510000;
const int MOD = 1000000007;

     signed main(){
        int n;
        cin>>n;
        int a,mxa=0;
        map<int,int>mp;
        for(int i=0;i<n;i++){
             cin>>a;mxa=max(a,mxa);
             mp[a]++;
        }
        int ans=0;
        for(auto&& i:mp){
             if(i.second==0)continue;
               if(i.second==1)ans++;
               for(int j=i.first;j<=mxa;j+=i.first){
                  if(mp.find(j)!=mp.end())  mp[j]=0;
               }
        }
        cout<<ans<<endl;

     }


 


 






    





      

        


Measured memory_bytes: 15980
import numpy as np
import sys 
import itertools as it 

readline = sys.stdin.readline 

N, M, X = map(int, readline().split())

CA = []
for i in range(N):
    CA.append(readline().split())


# 理解度をX以上にする組み合わせをすべて選び、最小金額を求める
# sigma_n{C_r}は4096通り、全探索でもよさそう
arr_CA = np.array(CA, np.int64)
achieve_X = []
for select_book_num in range(N):
    for combination in it.combinations(arr_CA, select_book_num + 1): # ここまでで4096ループ
        sum = np.sum(np.array(combination, np.int64), axis=0, dtype=np.int64)    
        if sum[1:].min() >= X:
            achieve_X.append(sum)


if len(achieve_X) == 0:
    print(-1)
else:
    arr_achieve_X = np.array(achieve_X)
    print(arr_achieve_X[:, 0].min())


Measured memory_bytes: 28100
#include <bits/stdc++.h>
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,n) FOR(i,0,n)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
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 (b<a) { a=b; return 1; } return 0; }
const ll INF = 1e10;
typedef pair<ll,ll> P;
ll n;
vector<vector<P>> graph(100005);
ll dist[100005];
bool done[100005];
void dfs(ll s){
    done[s] = true;
    for(P x:graph[s]){
        if (!done[x.first]){
            dist[x.first] = dist[s] + x.second;
            dfs(x.first);
        }
    }
}
int main(){
    ll u,v,d;
    cin >> n;
    rep(i,n){
        cin >> u >> v >> d;
        graph[u-1].push_back(P(v-1,d));
        graph[v-1].push_back(P(u-1,d));
    }
    dist[0] = 0;
    dfs(0);
    rep(i,n){
        if (dist[i]%2) PRINT("1");
        else PRINT("0");
    }
}


Measured memory_bytes: 9472
#include <bits/stdc++.h>
using namespace std;
//#define int long long

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,int> plli;
typedef pair<int,pii> pipii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n);i>0;i--)
#define rrep2(i,a,b) for (int i=(a);i>b;i--)
#define pb push_back
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()

const ll mod = 1e9 + 7;
const ll INF = 1<<30;
const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};
const int dx8[8] = {1, 1, 1, 0, 0, -1, -1, -1};
const int dy8[8] = {0, 1, -1, 1, -1, 0, 1, -1};
const double pi = 3.141592653589793;

int size;
vector<int> node((1 << 19) - 1);

void init(int n_, vector<int>& node) {
    size = 1;
    while (size < n_) size *= 2;
    for (int i = 0; i < 2 * size - 1; i++) node[i] = INT_MAX;
}

void update(int k, int a, vector<int>& node) {
    k += size - 1;
    node[k] = a;
    while (k > 0){
        k = (k - 1) / 2;
        node[k] = min(node[2 * k + 1], node[2 * k + 2]);
    }
}

int get_min(int queryL, int queryR, vector<int>& node, int k = 0, int nodeL = 0, int nodeR = -1) {
    if (nodeR == -1) nodeR = size;
    if (nodeR <= queryL || queryR <= nodeL) return INT_MAX;
    if (queryL <= nodeL && nodeR <= queryR) return node[k];
    else{
        int nodeM = (nodeL + nodeR) / 2;
        int vl = get_min(queryL, queryR, node, 2 * k + 1, nodeL, nodeM);
        int vr = get_min(queryL, queryR, node, 2 * k + 2, nodeM, nodeR);
        return min(vl, vr);
    }
}

int n, q;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n >> q;
    init(n, node);
    rep(i, q) {
        int com, x, y;
        cin >> com >> x >> y;
        if (com == 0) update(x, y, node);
        else cout << get_min(x, y + 1, node) << endl;
    }
}

Measured memory_bytes: 4780
#include<iostream>
#include<cstdio>
#include<algorithm>
#define ll long long
using namespace std;

const int maxn=3e3+15; 
ll n,mod;
ll g[maxn][maxn],c[maxn][maxn];
ll mul(ll a,ll b,ll p)
{
    ll r=0;
    for (;b;b>>=1,a=(a+a)%p) if (b&1) r=(r+a)%p;
    return r;
}
ll qpow(ll a,ll b,ll p)
{
    ll r=1;
    for (;b;b>>=1,a=mul(a,a,p)) if (b&1) r=mul(r,a,p);
    return r;
}
int main()
{
    scanf("%lld%lld",&n,&mod);    
    for (int i=1;i<=n;i++)
    {
        c[i][0]=c[i][i]=1;
        for (int j=1;j<i;j++)
            c[i][j]=(c[i-1][j]+c[i-1][j-1])%mod;
    }
    for (int i=0;i<=n;i++)
    {
        g[i][0]=1;
        for (int j=1;j<=i;j++)
            g[i][j]=(g[i-1][j-1]+g[i-1][j]*(j+1)%mod)%mod;    
    }
    ll ans=0;
    for (int i=0;i<=n;i++)
    {
        ll k=c[n][i];
        if (i&1) k=(mod-k)%mod;
        ll x=qpow(2,n-i,mod-1);//欧拉定理，注意模数
        x=qpow(2,x,mod);
        ll kind=qpow(2,n-i,mod);
        ll cnt=0,y=1;
        for (int j=0;j<=i;j++)
        {
            cnt=(cnt+(g[i][j]*y%mod))%mod;
            y=kind*y%mod;
        } 
        ans=(ans+(k*cnt%mod*x%mod))%mod;
    }
    printf("%lld\n",ans);
    return 0;
}

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

using namespace std;

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

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

int main(){
  fastIO;
  int a[4];
  for(int i = 0 ; i < 4; i ++ )
    cin >> a[i];
  sort(a,a+4);
  if(a[0]==1 && a[1] == 4 && a[2] == 7 && a[3] == 9){
    cout << "YES\n";
  }
  else{
    cout << "NO\n";
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int n,a,b,c,d;
    cin>>n;
    a=n%10;
    b=(n/10)%10;
    c=(n/100)%10;
    d=(n/1000)%10;
    if(a==b || b==c || c==d){
        cout<<"Bad";
    }
    else{
        cout<<"Good";
    }
    return 0;
}

Measured memory_bytes: 256
<?php
fscanf(STDIN,"%d %d",$a,$b);
//echo $a,"\n",$b,"\n";
if ($a<$b) {
    for ($i = 0; $i < $b; $i++) {
         echo $a;
    }
        
}else {
       for ($i = 0; $i < $a; $i++) {
            echo $b;
       }
    }
echo "\n";
?>


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

int main(){
    ll a,b,c,d;
    cin >> a >> b >> c >> d;
    cout << max({a*c,a*d,b*c,b*d}) << endl;

}

Measured memory_bytes: 3632
A = [list(map(int, input().split())) for _ in range(3)]
N = int(input())

for _ in range(N):
    B = int(input())
    for i in range(3):
        for j in range(3):
            if A[i][j] == B:
               A[i][j] = 0
ans = False     
for row in A:
    if sum(row) == 0:
        ans = True
for col in zip(*A):
    if sum(col) == 0:
        ans = True

if sum(A[i][i] for i in range(3)) == 0:
    ans =True
if sum(A[i][3 - i - 1] for i in range(3)) == 0:
    ans =True

print("Yes" if ans == True else "No" )

Measured memory_bytes: 3064
import java.util.*;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		long n = scan.nextLong();
		long k = scan.nextLong();
		
		//n-kiが最小になればいい
		
		long x = n%k;
		if(Math.abs(x-k) < x) {
			System.out.println(Math.abs(x-k));
		}else {
			System.out.println(x);
		}
		
	}	
}

Measured memory_bytes: 22100
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <iomanip>

using namespace std;
using ll = long long;

#define rep(i,N) for(int i=0;i<(int)N;++i)

int main() {
	string S;
	cin >> S;

	if (S == "Sunny") { cout << "Cloudy" << endl; }
	if (S == "Cloudy") { cout << "Rainy" << endl; }
	if (S == "Rainy") { cout << "Sunny" << endl; }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()
ll d1[4] = {1, -1, 0, 0};
ll d2[4] = {0, 0, 1, -1};

int main(){
    ll h, w;
    cin >> h >> w;
    ll ch, cw, dh, dw;
    cin >> ch >> cw >> dh >> dw;
    ch--; cw--; dh--; dw--;
    VS s(h);
    rep(i, 0, h) cin >> s[i];

    const ll inf = 1e18;
    VVL d(h, VL(w, inf));
    
    ll di[20] = {2, 2, 2, 2, 2, 1, 1, 1, 1, 0, 0, -1, -1, -1, -1, -2, -2, -2, -2, -2};
    ll dj[20] = {2, 1, 0, -1, -2, 2, 1, -1, -2, 2, -2, 2, 1, -1, -2, 2, 1, 0, -1, -2};

    auto chk = [&](ll i, ll j) {
        if(i < 0 || j < 0 || i >= h || j >= w) return false;
        else if(s[i][j] == '#') return false;
        else return true;
    };

    /* dijkstra's scope */{
        priority_queue<pair<ll,PL>, vector<pair<ll,PL>>, greater<pair<ll,PL>>> que;
        que.push({0, {ch, cw}});
        d[ch][cw] = 0;
        while(!que.empty()){
            auto q = que.top();
            que.pop();
            auto i = q.second.first;
            auto j = q.second.second;
            if(q.first > d[i][j]) continue;
            rep(k, 0, 4) {
                ll ni = i + d1[k];
                ll nj = j + d2[k];
                if(!chk(ni, nj)) continue;
                if(d[ni][nj] <= q.first) continue;
                d[ni][nj] = q.first;
                que.push({d[ni][nj], {ni, nj}});
            }
            rep(k, 0, 20) {
                ll ni = i + di[k];
                ll nj = j + dj[k];
                if(!chk(ni, nj)) continue;
                if(d[ni][nj] <= q.first + 1) continue;
                d[ni][nj] = q.first + 1;
                que.push({d[ni][nj], {ni, nj}});
            }
        }
    }

    if(d[dh][dw] == inf) cout << -1 << endl;
    else cout << d[dh][dw] << endl;
    return 0;
}

Measured memory_bytes: 13616
#%%
a = list(input())
c = [0] * 26
alpha2num = lambda x: ord(x) - ord('a') 

for i in range(len(a)):
    c[alpha2num(a[i])] += 1

ans = 1 + (len(a)*(len(a)-1)//2)
for i in range(26):
    ans -= c[i] * (c[i] - 1) //2

print(ans)

#%%


Measured memory_bytes: 4840
#include<algorithm>
#include<stack>
#include<ctime>
#include<cstring>
#include<cmath>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<queue>
using namespace std;
inline int read(){
	int num=0,f=1;char x=getchar();
	while(x<'0'||x>'9'){if(x=='-')f=-1;x=getchar();}
	while(x>='0'&&x<='9'){num=num*10+x-'0';x=getchar();}
	return num*f;
}
int k;
int main(){
	k=read();
	if(k%2==0||k%5==0)puts("-1");
	else{
		int t=7%k,cnt=1;
		while(t){t=(t*10+7)%k;++cnt;}
		printf("%d\n",cnt);
	}

	return 0;
}


Measured memory_bytes: 3744
weather = input()
raincount=0
cont=0
for  i in range(3):
    if weather[i]=="R" and cont==0:
           raincount=raincount+1
    elif weather[i]=="R" and cont==1:
           raincount=1
           cont=0
    elif weather[i] == "S":
        cont=1

print(raincount)

Measured memory_bytes: 9016
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#define ll long long
#define inf 0x3f3f3f3f
#define maxn 200010
inline ll read()
{
	ll x=0; char c=getchar(),f=1;
	for(;c<'0'||'9'<c;c=getchar())if(c=='-')f=-1;
	for(;'0'<=c&&c<='9';c=getchar())x=x*10+c-'0';
	return x*f;
}
inline void write(ll x)
{
	static char buf[20];
	int len=0;
	if(x<0)putchar('-'),x=-x;
	for(;x;x/=10)buf[len++]=x%10+'0';
	if(!len)putchar('0');
	else while(len)putchar(buf[--len]);
}
inline void writesp(ll x){write(x); putchar(' ');}
inline void writeln(ll x){write(x); putchar('\n');}
int a[maxn];
int n,m;
int main()
{
	n=read(); m=read();
	if(m==1){
		writeln(n);
		if(n==1){
			writeln(1);
			writeln(n);
		}
		else{
			writeln(2);
			writesp(n-1); writeln(1);
		}
		return 0;
	}
	int cnt=0;
	for(int i=1;i<=m;i++){
		a[i]=read();
		cnt+=(a[i]&1);
	}
	if(cnt>2){
		puts("Impossible"); return 0;
	}
	int flag=0;
	for(int i=1;i<=m;i++)
		if(a[i]&1){
			if(!flag)std::swap(a[1],a[i]),flag=1;
			else std::swap(a[m],a[i]);
		}
	for(int i=1;i<=m;i++)
		writesp(a[i]);
	putchar('\n');
	if(a[1]==1){
		writeln(m-1);
		for(int i=2;i<m;i++)
			writesp(a[i]);
		writeln(a[m]+1);
	}
	else{
		writeln(m);
		writesp(a[1]-1);
		for(int i=2;i<m;i++)
			writesp(a[i]);
		writeln(a[m]+1);
	}
	return 0;
}

Measured memory_bytes: 128
#写経

n=input()
a=list(map(int,input().split()))
b=[abs(x)for x in a]

#sum(x<0 for x in a)%2 ここで負の値の個数数えてるのが！
print(sum(b)-2*min(b)if sum(x<0 for x in a)%2 else sum(b))

Measured memory_bytes: 14212
import java.util.Scanner;

class Main {

    private static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        int a = sc.nextInt(), b = sc.nextInt(), k = sc.nextInt();
        int tmp = a;
        int i;
        for (i = a; i < a + k && i <= b; i++) {
            System.out.println(i);
            tmp = i;
        }
        tmp++;
        for (i = Math.max(b - k + 1, tmp); i <= b; i++) {
            System.out.println(i);
        }
    }
}

Measured memory_bytes: 21972
#include<stdio.h>

int main(void) {
	char s[101], p[101];
	char ss[201];
	int i, j;
	int l;
	int lp = 0;
	int canMake = 0;
	
	
	scanf("%s", &s);
	scanf("%s", &p);
	
	
	for(i = 0; s[i] != '\0'; i++) {
		ss[i] = s[i];
	}
	l = i;
	
	for(i = 0; s[i] != '\0'; i++) {
		ss[l+i] = s[i];
	}
	ss[l+i+1] = '\0';
	
	
	
	for(i = 0; p[i] != '\0'; i++) {
		lp++;
	}
	
	for(i = 0; i < l*2-lp; i++) {
		for(j = 0; j < lp; j++) {
			if(ss[i+j] != p[j]) {
				break;
			}
			if(j == lp-1) {
				canMake = 1;
			}
		}
	}
	
	if(canMake) {
		printf("Yes\n");
	} else {
		printf("No\n");
	}
	
	return 0;
}

Measured memory_bytes: 524
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int m = in.nextInt();
		int[] x = new int[n + 1];
		int[] y = new int[m + 1];
		x[0] = in.nextInt();
		y[0] = in.nextInt();

		for (int i = 1; i < n + 1; i++) {
			x[i] = in.nextInt();
		}
		for (int i = 1; i < m + 1; i++) {
			y[i] = in.nextInt();
		}

		Arrays.sort(x);
		Arrays.sort(y);

		if (y[0] <= x[x.length - 1]) {
			System.out.println("War");
		} else {
			System.out.println("No War");
		}

	}

}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  unsigned long X,Y,Z,K;
  cin >> X;
  cin >> Y;
  cin >> Z;
  cin >> K;
  vector<unsigned long> A(X);
  vector<unsigned long> B(Y);
  vector<unsigned long> C(Z);
  for (int i = 0; i < X; i++) {
    cin >> A.at(i);
  }
   for (int i = 0; i < Y; i++) {
    cin >> B.at(i);
  }
   for (int i = 0; i < Z; i++) {
    cin >> C.at(i);
  }
  vector<unsigned long> D(X*Y);
  for (int i = 0; i<X;i++){
  	for (int j = 0; j<Y;j++){
    	D.at(i*Y+j)=A.at(i)+B.at(j);
    }
  }
  
  sort(D.begin(), D.end(), 
     [](const unsigned long& x, const unsigned long& y) { return x > y;});
  
  int L = min(K,X*Y);
  vector<unsigned long> E(L*Z);
  for (int i = 0; i<L;i++){
  	for (int j = 0; j<Z;j++){
    	E.at(i*Z+j)=D.at(i)+C.at(j);
    }
  }
  sort(E.begin(), E.end(), 
     [](const unsigned long& x, const unsigned long& y) { return x > y;});
  for (int i=0;i<K;i++){
   cout<<E.at(i)<<endl; 
  }
  
}

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

int N, M, R;
ll dp[200][200];
int r[10];
bool visited[10];
ll answer = INT_MAX;

void search(int index, int from, ll distance) {
    if (index == R) {
        answer = min(answer, distance);
        return;
    }
    rep(i, R) {
        if (visited[i]) continue;
        int to = r[i];
        visited[i] = true;
        if (from < 0) {
            search(index + 1, to, 0);
        } else {
            search(index + 1, to, distance + dp[from][to]);
        }
        visited[i] = false;
    }
}

int main()
{
    cin >> N >> M >> R;
    rep(i, N) rep(j, N) dp[i][j] = INT_MAX;
    rep(i, R) {
        cin >> r[i];
        r[i]--;
    }

    rep(i, M) {
        int a, b, c;
        cin >> a >> b >> c;
        a--;b--;
        if (dp[a][b] > c) {
            dp[a][b] = dp[b][a] = c;
        }
    }
    rep(k, N)
        rep(i, N)
            rep(j, N)
                dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]);
    search(0, -1, 0);
    cout << answer << endl;
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <cmath>
using namespace std;
typedef long long i64;
typedef long double ld;
typedef pair<i64,i64> P;
#define rep(i,s,e) for(int i = (s);i <= (e);i++)
typedef long long i64;

template <i64 MOD> struct ModInt {
  i64 value;

  ModInt(i64 v = 0) { value = v % MOD; }

  operator i64() { return value; }
  ModInt<MOD> operator+(int v) { return (value + v) % MOD; }
  ModInt<MOD> operator+(i64 v) { return (value + v) % MOD; }

  ModInt<MOD> operator-(i64 v) {
    v %= MOD;
    return (MOD + value - v) % MOD;
  }

  ModInt<MOD> operator*(i64 v) { return (value * v) % MOD; }
};

int n;

vector<int> c;
const i64 mod = 1e9 + 7;
vector<vector<ModInt<mod>>> dp(404,vector<ModInt<mod>>(404));
int main(){
    cin >> n;
    for(int i = 0;i < n;i++){
		char u;
		cin >> u;
		if(u == 'U') c.push_back(-1);
		if(u == 'D') c.push_back(1);
    }
	dp[0][0] = 1;
	n = c.size();
	for(i64 i = 0;i < n;i++){
		for(i64 j = 0;j <= n;j++){
			if(c[i]==1){
				dp[i + 1][j] = dp[i + 1][j] + dp[i][j] * j;
				if(j > 0) dp[i + 1][j - 1] = dp[i + 1][j - 1] + dp[i + 1][j] * j;
			}
			else{
				dp[i + 1][j] = dp[i + 1][j] + dp[i][j] * j;
				dp[i + 1][j + 1] = dp[i + 1][j + 1] + dp[i][j];
			}
		}
	}
	cout << dp[n][0] << endl;
}



Measured memory_bytes: 3988
#include <iostream>
#include <set>

using namespace std;

const int N = 2e5 + 10;

string s[N];
set<string> res;

int main() {
	int n;
	cin >> n;
	
	for (int i = 1; i <= n; i++) {
		cin >> s[i];
		res.insert(s[i]);
	}
	
	cout << res.size() << '\n';
	
	return 0;
}

Measured memory_bytes: 25344
#include <bits/stdc++.h>
using namespace std;
#define f(i, k, n) for (int i = k; k < n ? i < n : i > n; k < n ? i += 1 : i -= 1)
#define ll long long
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define len(s) s.size()
#define all(x) x.begin(), x.end()
#define min3(a, b, c) min(a, min(b, c))
#define max3(a, b, c) max(a, max(b, c))
#define tr(it, a) for (auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef map<int, int> mii;
typedef vector<pii> vpii;
typedef vector<vi> vvi;

void ipgraph(int n, int m);
void dfs(int u, int par);

const int mod = 1'000'000'007;
const int N = 3e5 + 1, M = N + 1;
//==================================

vi g[N];
int a[N];

void solve()
{
    int n, m, ans = 0, k;
    cin>>n;
    cout<<ceil((1.0*n)/1000)*1000-n;
}

int main()
{

#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

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

void ipgraph(int n, int m)
{
    int i, u, v;
    while (m--)
    {
        cin >> u >> v;
        g[u].pb(v);
        g[v].pb(u);
    }
}

void dfs(int u, int par)
{
    for (int v : g[u])
    {
        if (v == par)
            continue;
        dfs(v, u);
    }
}

Measured memory_bytes: 10832
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, o, n) for (auto i = (o); (i) < (n); ++(i))
#define FOR1(i, n) FOR(i, 1, n+1)
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (auto i = (n)-1; (i) >= 0; --i)
#define REPI(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define REPIR(itr, v) for (auto itr = v.rbegin(); itr != v.rend(); ++itr)
#define fi first
#define se second
#define ll long long
#define int long long
#define V2(name, h, w) vector<vector<int> > name((h), vector<int>(w));

#define dl(line) cerr << "RUN: until " << (line) << "th line." << endl
#define dv(name, value) cerr << (name) << " is " << (value) << endl
#define da(v)  cerr << "["; REPI(itr, v){cerr << *itr << (itr != --v.end() ? ", " : "");} cerr << "]" << endl


void solve(long long N, long long K, std::vector<long long> H){
  sort(H.begin(), H.end());
  int sum = 0;
  REP(i, N-K) {
    sum += H.at(i);
  }
  cout << sum << endl;
}

signed main(){
  long long N;
  scanf("%lld",&N);
  long long K;
  scanf("%lld",&K);
  std::vector<long long> H(N);
  for(int i = 0 ; i < N ; i++){
    scanf("%lld",&H[i]);
  }
  solve(N, K, std::move(H));
}


Measured memory_bytes: 1792
main = do
  line <- getLine
  let 
    n = read line :: Int
    func n i ret
      | i > n      = ret
      | (mod n i) == 0 = func n (i+1) (ret+1)
      | otherwise  = func n (i+1) ret
    func2 n ret
      | n <= 0            = ret
      | (mod n 2) == 0    = func2 (n-1) ret
      | (func n 1 0) == 8 = func2 (n-2) (ret+1)
      | otherwise         = func2 (n-2) ret
    in
      putStrLn $ show $ func2 n 0


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

using namespace std;
#define ll  long long
#define ld  long double

#define endl '\n'
#define FAST ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const ll mod = 1000000007;
const double PI = 3.141592653589793238463;
const int MAXN=1e5 + 5;
bool comp(pair<int,int>p1,pair<int,int>p2)
{
    return p1.second<p2.second;
}
ll gcd (ll a,ll b)
{
    if(a==0)
        return b;
    return gcd(b%a,a);
}
ll lcm(ll a, ll b)
{
    return a/gcd(a, b) * b;
}

int main()
{
    FAST
int t;
cin>>t;
ll a;
cin>>a;
t--;
ll ans=a;
while(t--)
{
    ll a;
    cin>>a;

    ans=lcm(ans,a);
}
cout<<ans<<endl;

    return 0;

}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int array[9];
int func(int x){
    int idx;
    if(1<=x && x<= 399) idx = 0;
    else if(400<=x && x <= 799) idx = 1;
    else if(800<=x && x <= 1199) idx = 2;
    else if(1200<=x && x <= 1599) idx = 3;
    else if(1600<=x && x <= 1999) idx = 4;
    else if(2000<=x && x <= 2399) idx = 5;
    else if(2400<=x && x <= 2799) idx = 6;
    else if(2800<=x && x <= 3199) idx = 7;
    else idx = 8;
    return idx;
}
int main(void){
    int n,x,kind=0;
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> x;
        int index = func(x);
        array[index]++;
    }
    for(int i=0;i<8;i++) if(array[i] > 0) kind++;
    if(kind == 0) cout<<1<<" "<<array[8];
    else cout<<kind<<" "<< kind + array[8];
}
    


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int INF=1e7;
int a,b,c,d,e,_a,_b,_c,_d,_e,mini=0;
bool __a=true,__b=true,__c=true,__d=true,__e=true;
int main() {
	scanf("%d%d%d%d%d",&a,&b,&c,&d,&e);
	_a=a%10;_b=b%10;_c=c%10;_d=d%10;_e=e%10;
	if(_a==0) _a=INF,__a=false;
	if(_b==0) _b=INF,__b=false;
	if(_c==0) _c=INF,__c=false;
	if(_d==0) _d=INF,__d=false;
	if(_e==0) _e=INF,__e=false;
	mini=min(min(_a,_b),min(min(_c,_d),_e));
	if(!__a) _a=10;
	if(!__b) _b=10;
	if(!__c) _c=10;
	if(!__d) _d=10;
	if(!__e) _e=10;
	if(mini==INF) mini=10;
	printf("%d",a+b+c+d+e+50-_a-_b-_c-_d-_e+mini-10);
	return 0;
}


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

#define INF 1 << 29
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)

using namespace std;

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

void gen_sosuu(int sosuu[]){
  REP(i,100010){
    sosuu[i] = true;
  }
  sosuu[0] = false;
  sosuu[1] = false;
  sosuu[2] = true;
  FOR(i,2,sqrt(100000)+1){
    if(sosuu[i] == false) continue;
    for(int j = 2; i*j<=100000;j++){
      //printf("%d %d %d\n",i*j,i,j);
      sosuu[i*j] =false;
    }
  }
}

int n,a,b;
vector<double> vec;
double mi = 0;
int in = 0;
ll dp[51][51]={{0}};

int main(){
  scanf("%d %d %d",&n,&a,&b);
  REP(i,n){
    double v;
    scanf("%lf",&v);
    vec.push_back(v);
  }
  sort(vec.begin(),vec.end(),greater<ll>());
  double sum = 0;
  double ans = 0;
  mi = vec[0];
  REP(i,a){
    sum += vec[i];
    if(mi != vec[i]){
      mi = vec[i];
      in = i;
    }
  }
  ll cnt = 0;
  ll cnt_a = 0;
  REP(i,n){
    if(mi == vec[i]){
      cnt++;
      if(i<a) cnt_a++;
    }
  }
  //cntC(a-in)
  //=cnt!/(a-in)!(cnt-a+in)!
  dp[0][0] = 1;//0C0
  dp[1][0] = 1;
  dp[1][1] = 1;
  for(int i = 2;i<51;i++){
    dp[i][0] = 1;
    dp[i][i] = 1;
    for(int j = 1; j<i; j++){
      dp[i][j] = dp[i-1][j-1]+dp[i-1][j];
    }
  }
  ans = sum / a;
  printf("%lf\n",ans);
  if(vec[0] != vec[a-1]){
    printf("%lld\n",dp[cnt][cnt_a]);
    return 0;
  }
  ll k = 0;
  for(int i = a; i<=b;i++){
    k += dp[cnt][i];
  }
  printf("%lld\n",k);

}


Measured memory_bytes: 256
acgt = ["A", "C", "G", "T"]

s = gets.chomp

count = 0
count_list = []
mode = false

s.each_char do |c|
    if acgt.include?(c)
        count += 1
    else
        count_list.push(count)
        count = 0
    end
end

count_list.push(count)

print count_list.max.to_s

Measured memory_bytes: 1788
N = int(input())
target = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(target[N-1])

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

int main()
{
	int x, y, z;
	
	scanf("%d%d%d", &x, &y, &z);
	if (x > y) swap(x, y);
	if (x > z) swap(x, z);
	if (y > z) swap(y, z);
	printf("%d\n", z - y + y - x);
}


Measured memory_bytes: 256
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


# 初項s, 交差dのn個の数列の和
def sum_of_arithmetic_progression(s, d, n):
    return n * (2 * s + (n - 1) * d) // 2


# aとbの最大公約数
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


# aとbの最小公倍数
def lcm(a, b):
    g = gcd(a, b)
    return a / g * b


def main():
    W, H, x, y = map(int, input().split())

    area = W * H / 2.0
    ans = 0
    if 2 * x == W and 2 * y == H:
        ans = 1
    print(area, ans)


if __name__ == '__main__':
    main()


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

int main(){
	int k;
	cin >> k;
	queue<ll> que;

	int count = 0;
	ll n;
	rep(i,9)que.push(i);
	while(count != k){
		n = que.front();
		if(n%10 != 0) que.push(n*10+(n%10)-1);
		que.push(n*10+(n%10));
		if(n%10 != 9) que.push(n*10+(n%10)+1);
		que.pop();
		count++;
		//cout << "count:"<< count<<" ,n:"<<n<<endl;
	}
	cout << n << endl;

	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <math.h>
#include <string>
#include <algorithm>
#include <ctype.h>
#include <vector>
#include <numeric>
using namespace std;

#define ll long long int
#define rep(i, a, n) for (int i = a; i < n; i++)
#define INF 1e9
#define LINF 1e17
#define MOD (int)(1e9 + 7)
#define pi 3.141592653589
#define pii pair<int, int>
#define vi vector<int>
#define ALL(a) (a).begin(), (a).end()
#define sort_v(a) sort(a.begin(), a.end())

void print(bool a)
{
    if (a == true)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

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

int main()
{
    int a[5], k;
    cin >> a[0] >> a[1] >> a[2] >> a[3] >> a[4] >> k;
    rep(i, 0, 5)
    {
        rep(j, i, 5)
        {
            if (a[j] - a[i] > k)
            {
                cout << ":(" << endl;
                return 0;
            }
        }
    }
    cout << "Yay!" << endl;
}


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

#define fastIO ios_base::sync_with_stdio(false)
#define for0N(data_type, var, initial, upper) for(data_type var = initial; var < upper; var++)
#define MOD0 1000000007

typedef long long ll;
typedef unsigned long long ull;

using namespace std;

int N;
vector<ull> h, a, fenwick;

void update(ull i, ull v) {
    for (++i; i < N + 10; i += i & (-i)) fenwick[i] = max(fenwick[i], v);
}

ull get(ull i) {
    ull _max = 0;
    for (++i; i > 0; i -= i & (-i)) _max = max(_max, fenwick[i]);
    return _max;
}

int main() {
    fastIO;

    cin >> N;

    h.resize(N + 10);
    a.resize(N + 10);
    fenwick.resize(N + 10);

    for0N (int, i, 0, N)
        cin >> h[i];
    for0N (int, i, 0, N)
        cin >> a[i];

    for0N(int, i, 0, N)
        update(h[i], get(h[i]) + a[i]);

    cout << get(N);
}

Measured memory_bytes: 4992
// Aizu 2205: Lottery Checker
// 2017.9.20 bal4u@uu

#include <stdio.h>

char k[102][10];
int v[102];

int main()
{
	int n, m, i, j, ans;
	char a[10];

	while (scanf("%d%d", &n, &m) && n) {
		for (i = 0; i < n; i++) scanf("%s%d", k[i], v+i);
		ans = 0; while (m-- > 0) {
			scanf("%s", a);
			for (i = 0; i < n; i++) {
				for (j = 0; j < 8; j++) if (k[i][j] != '*' && k[i][j] != a[j]) break;
				if (j == 8) { ans += v[i]; break; }
			}
		}
		printf("%d\n", ans);
	}
	return 0;
}

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

int main() {
    int n;
    cin>>n;
    vector<int> a(n);
    for(int i=0; i<n; i++)
        cin>>a[i];

    long minA = 0;
    long sumA = 0;
    for(int i=0; i<n; i++) {
        sumA += a[i];
        if (i%2 == 0) {
            if (sumA <= 0) {
                minA += abs(sumA) + 1;
                sumA += abs(sumA) + 1;
            }
        }
        else {
            if(sumA >= 0) {
                minA += abs(sumA) + 1;
                sumA -= abs(sumA) + 1;
            }
        }
    }

    long minB=0;
    long sumB=0;
    for(int i=0; i<n; i++) {
        sumB += a[i];
        if (i%2 != 0) {
            if (sumB <= 0) {
                minB += abs(sumB) + 1;
                sumB += abs(sumB) + 1;
            }
        }
        else {
            if (sumB >= 0) {
                minB += abs(sumB)+1;
                sumB -= abs(sumB)+1;
            }
        }
    }
    cout<<min(minA, minB)<<endl;

    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <numeric>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <bitset>
#include <queue>
#include <unordered_set>

using namespace std;
typedef long long ll;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
#define rep(i, n) for(int i = 0;i < n;i++)
const long long INF = 1LL << 61;

int MOD = 1000000007;


int main(){
    std::ios_base::sync_with_stdio(false);

    int a,b,c;
    cin >> a >> b >> c;

    if(b>=a && b>=c && c>=a){
        cout << "Yes" << endl;
    } else if (b<=a && b<=c && c<=a){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main() {
    int x;
    cin >> x;
    int total = 0;
    for (int i = 0; i <= 1000; ++i) {
        total += x;
        if (total % 360 == 0) {
            cout << i + 1 << endl;
            return 0;
        }
    }
}

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

bool kaibun(string S){
  string T=S;
  for(ll i=0;i<S.size();i++){
    T.at(i)=S.at(S.size()-1-i);
  }
  if(S==T){
    return true;
  }
  else {
    return false;
  }
}

int main() {
  string S;
  cin >> S;
  ll N=S.size();
  string S1="";
  string S2="";
  for(ll i=0;i<N;i++){
    if(i<(N-1)/2){
      S1+=S.at(i);
    }
    else if(i>=(N+3)/2-1){
      S2+=S.at(i);
    }
  }
  if(kaibun(S1) && kaibun(S2) && kaibun(S)){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}


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

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

template<typename T> inline T mini(T& x, T y) { return x = min(x, y); }
template<typename T> inline T maxi(T& x, T y) { return x = max(x, y); }
template <typename T> T rand(T x, T y) { return rand() % (y - x + 1) + x; }
mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());


class ATakoyaki {
public:

  void solve(std::istream& cin, std::ostream& cout) {
    int n , x ,t;
    cin >> n >> x >> t;
    cout << (n + x - 1) / x * t << '\n';

  }
};

int32_t main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
	ATakoyaki solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 3600
import bisect
import cmath
import heapq
import itertools
import math
import operator
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353

A = list(map(int, sys.stdin.buffer.readline().split()))
A = np.array(A, dtype=int)

ans = A.max() - A.min()
print(ans)


Measured memory_bytes: 13424
n,m=map(int,input().split())
X=list(sorted(map(int,input().split())))
if n>=m:
    print(0)
else:
    D=[]
    for i in range(m-1):
        D.append(X[i+1]-X[i])
    D.sort()
    print(sum(D[:m-n]))

Measured memory_bytes: 13964
import math
N=int(input())
a=1
b=N
for i in range(1,N):
  a*=i
  b*=i
XY=[list(map(int,input().split())) for i in range(N)]
ans=0
for j in range(1,N):
  i=0
  while i+j<N:
    ans += math.sqrt((XY[i][0]-XY[i+j][0])**2 + (XY[i][1]-XY[i+j][1])**2)*a*2
    i+=1
print(ans/b)

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

void solve() {
	ll n, k;
	cin >> n >> k;
	vector <ll> town;
	for (ll i = 0, ele; i < n; i++) {
		cin >> ele;
		town.push_back(ele);
	}
	unordered_map <ll, ll> visited;
	ll i = 0;
	while (1) {
		if (k == 0) {
			cout << i + 1;
			return;
		}
		else {
			k--;
		}
		visited[town[i]]++;
		if (visited[town[i]] == 2) {
			break;
		}
		i = town[i] - 1;
	}
	//cout << k << endl;
	//cout << start;
	ll len = 0;
	while (1) {
		if (visited[town[i]] == 3) {
			break;
		}
		visited[town[i]]++;
		len++;
		i = town[i] - 1;
	}
	k %= len;
	while (k--) {
		i = town[i] - 1;
	}
	cout << town[i];
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
# ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
# endif
	solve();
	return 0;
}

Measured memory_bytes: 11828
#include <iostream>
#include <set>
#include <vector>
#include <string>
#include <algorithm>
#include <iterator>
#include <map>
#include <utility>
#include <list>
#include <climits>
#include <bitset>
#include <numeric>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, n) for(auto i = (n).begin(); i != (n).end(); i++)
#define in_arr(type, a, n) copy_n(istream_iterator<type>(cin), n, (a).begin());
#define ll long long int

int main(){
    int n;
    cin >> n;
    vector<ll> a(n);
    ll ans = LLONG_MAX;
    in_arr(ll, a, n);
    ll s = 0;
    ll b = accumulate(a.begin(), a.end(), (ll)0);
    // bear
    for(int i = 0; i < n - 1; i++){
        s += a[i];
        b -= a[i];
        if(abs(s - b) < ans){
            ans = abs(s - b);
        }
        //ans = min(ans, abs(s - b));
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
integer N,ans
read*,N
ans=0
if(N==10**5)then
  ans=90909
else if(N>=10**4)then
  ans=909+N-10**4+1
else if(N>=10**3)then
  ans=909
else if(N>=10**2)then
  ans=9+N-10**2+1
else if(N>=10)then
  ans=9
else
  ans=N
endif
print"(I0)",ans
end

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        try (Scanner in = new Scanner(System.in)) {
            int N = in.nextInt();
            int K = in.nextInt();
            int count = 0;
            for (int n = 1; n <= N; n += 2) {
                count++;
            }
            System.out.println(count >= K ? "YES" : "NO");
        }
    }
}


Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
using lint     = long long;
const lint inf = 1LL << 60;
const lint mod = 1000000007;

// list up all factors
template <typename T>
set<T> factors(T a) {
    set<T> facs;
    for (T i = 1; i * i <= a; ++i) {
        if (a % i == 0) {
            facs.insert(i);
            facs.insert(a / i);
        }
    }
    return facs;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    lint n;
    cin >> n;
    auto facs = factors(n);
    lint ret = inf;
    for (auto &f : facs) {
        ret = min(ret, (f-1) + (n/f-1));
    }
    cout << ret << "\n";
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
// Begin Header {{{
#define all(x) (x).begin(), (x).end()
#define lli long long int
#define rep(i,n) for(lli i=0; i<n; i++)
#define loop(i, j, n) for(lli i=j; i<n; i++)
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) < (b) ? (a) : (b))
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
//Function
lli combi(lli n, lli r)
{
	if(r==0 || r==n) return 1;
	else return combi(n-1,r) + combi(n-1,r-1);
}
lli sigma1(lli n){return n*(n+1)/2;}
lli sigma2(lli s, lli n){return sigma1(n) - sigma1(s -1);}
using namespace std;
// }}} End Header

lli body(lli a, lli b){
	return (a-b)*(a-b);
}
int main()
{
	lli n, k;
	cin >> n >> k;
	vector<lli> h(n);
	rep(i,n){
		cin >> h[i];
	}
	sort(all(h));
	lli ans=0;
	rep(j,n-k){
		ans += h[j];
	}
	cout << ans << endl;
 	return 0;
}


Measured memory_bytes: 1920
#include <stdio.h>

int main(){
  int w, h;
  while(1){
    scanf("%d %d", &h, &w);
    if(!h)break;
    int sq = w*w+h*h;
    h++;
    while(1){
      for(w=h+1;sq>(w*w+h*h);w++);

      if(sq==(w*w+h*h)){
        printf("%d %d\n", h, w);
        break;
      }
      if(h+1==w){
        sq++;
        h=1;
      }
      else h++;
    }
  }
  return 0;
}

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

int main() {
  int n, a, b, c, d;

  cin >> n;

  d = n % 10;
  n /= 10;
  c = n % 10;
  n /= 10;
  b = n % 10;
  a = n / 10;

  if (b != c)
    cout << "No" << endl;
  else if (a == c || b == d)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main()
{
	string s;
	string week[7] = { "MON","TUE","WED","THU","FRI","SAT","SUN" };
	cin >> s;
	for (int i = 0; i < 7; i++)
	{
		if (s == week[i])
		{
			if (s == "SUN")
				cout << 7 << endl;
			else
				cout << 6-i << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
//sohag_ict//
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,i,j,sum=0;
    cin>>n;
    int a[n];
    for(i=0;i<n;i++)
    {
        cin>>a[i];
    }
    for(i=0;i<n;i++)
    {
        for(j=i+1;j<n;j++)
        {
            sum+=a[i]*a[j];
        }
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll mod = 1e9 + 7;
#define pival 3.14159265359
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pqq priority_queue
#define all(a) a.begin(),a.end()
#define sz(a) (ll)(a.size())
ll power(ll x,ll y,ll p) 
{ 
    ll res=1;  
    x=x%p;
    while (y > 0) 
    { 
        if(y&1) 
            res=(res*x)%p; 
        y=y>>1;
        x=(x*x)%p;   
    } 
    return res; 
}
ll dp[1005][1005];
char arr[1005][1005];
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
 	ll i,j,h,w;
 	cin >> h >> w;
 	for(i=0;i<h;i++)
 		for(j=0;j<w;j++)
 			cin >> arr[i][j];
 	for(i=0;i<h;i++)
 		for(j=0;j<w;j++)
 		{
 			if(i == 0 && j == 0)
 				dp[i][j] = 1;
 			else if(i == 0)
 			{
 				if(arr[i][j-1] == '.')
 					dp[i][j] = dp[i][j-1];
 			}
 			else if(j == 0)
 			{
 				if(arr[i-1][j] == '.')
 					dp[i][j] = dp[i-1][j];
 			}
 			else
 			{
 				if(arr[i][j-1] == '.')
 					dp[i][j] += dp[i][j-1];
 				if(arr[i-1][j] == '.')
 					dp[i][j] += dp[i-1][j];
 				dp[i][j] %= mod;
 			}
 		}
 	cout << dp[h-1][w-1] << endl;
	return 0;
}

Measured memory_bytes: 9088
//#define _USE_MATH_DEFINES
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
#pragma GCC diagnostic ignored "-Wmissing-declarations"
#define FINAL_OUT(x) {cout << (x) << '\n'; exit(0); }
//inline int safe_mul(const int x, const int y) __attribute__ ((warn_unused_result));

int const maxn = 100005;
vector<int> gr[3 * maxn];


int main()
{
//    freopen("in.txt","r", stdin);
//    freopen("out.txt", "w", stdout);
//    cout << fixed << setprecision(20);
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    int n,m;
    cin >> n >> m;

    for (int i = 0; i < m; ++i) {
        int x,y;
        cin >> x >> y;
        gr[x].push_back(y + maxn);
        gr[x + maxn].push_back(y + maxn * 2);
        gr[x + 2 * maxn].push_back(y);
    }

    vector<int> dist(3 * maxn, -1);
    queue<int> qu;
    int s,t;
    cin >> s >> t;
    dist[s] = 0;
    qu.push(s);
    while (!qu.empty()) {
        int v = qu.front();
        qu.pop();
        for (int ne : gr[v]) {
            if (dist[ne] == -1) {
                dist[ne] = dist[v] + 1;
                qu.push(ne);
            }
        }
    }
    if (dist[t] >= 0)
        dist[t] /= 3;

    cout << dist[t] << endl;
}


Measured memory_bytes: 17792
N=int(input())
XL=[]
for i in range(N):
    X,L=[int(x) for x in input().rstrip().split()]
    XL.append([X-L,X+L])
XL=sorted(XL,key=lambda x:x[1])


cnt=0
prev=-float('inf')
for l,r in XL:
    if prev<=l:
        prev=r
        cnt+=1
print(cnt)

Measured memory_bytes: 22144
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, e) for (int i = (int)(s); i <= (int)(e); i++)
#define printYesNo(is_ok) puts(is_ok ? "Yes" : "No");
#define SORT(v) sort(v.begin(), v.end());
#define RSORT(v) sort(v.rbegin(), v.rend());
#define REVERSE(v) reverse(v.begin(), v.end());

template <typename T>
void printlnVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << endl;
  }
}

template <typename T>
void printVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << " ";
  }
  cout << endl;
}

int main()
{
  int N;
  cin >> N;
  vector<long long> A(N);
  rep(i, N)
  {
    cin >> A[i];
  }

  vector<long long> pow10(N);
  rep(i, N)
  {
    long long temp = A[i];
    while (temp != 0)
    {
      temp /= 10;
      pow10[i]++;
    }
    pow10[i]--;
  }
  SORT(A);
  long long ans = 1;
  long double ansd = 1;
  long long POW10MAX = pow(10, 18);
  rep(i, N)
  {
    long long temp = ans;
    long long temppo10 = -1;
    while (temp != 0)
    {
      temppo10 += 1;
      temp /= 10;
    }

    ansd *= A[i];
    ans *= A[i];
    if (temppo10 + pow10[i] > 18)
    {
      cout << -1 << endl;
      return 0;
    }
    if (ansd > POW10MAX || ans > POW10MAX)
    {
      cout << -1 << endl;
      return 0;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4792