akhauriyash/Code-Regression huggingface dataset:
/*
 _     _                             
| |__ | |__   __ _  __ _ _   _  __ _ 
| '_ \| '_ \ / _` |/ _` | | | |/ _` |
| |_) | | | | (_| | (_| | |_| | (_| |
|_.__/|_| |_|\__,_|\__, |\__, |\__,_|
                   |___/ |___/       
*/
#include<bits/stdc++.h>

#define ll          long long
#define pb          push_back
#define ppb         pop_back
#define	endl		'\n'
#define mii         map<ll int,ll int>
#define msi         map<string,ll int>
#define mis         map<ll int, string>
#define mpi         map<pair<ll int,ll int>,ll int>
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define vs          vector<string>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define what_is(x)  cerr << #x << " is " << x << endl;
using namespace std;

#define N  100005

ll int n,k;

ll int arr[N];

ll int fun(ll int k1,ll int k2,ll int l,ll int r)
{
	ll int stps=l+n-r+1;
	if(stps>k1) return -1e18;
	vi v;
	ll int sm=0;
	for(ll int i=1;i<=l;i++)
	{
		if(arr[i]>=0)
		{
			sm+=arr[i];
		}
		else
		{
			v.pb(-arr[i]);
		}
	}
	for(ll int i=r;i<=n;i++)
	{
		if(arr[i]>=0)
		{
			sm+=arr[i];
		}
		else
		{
			v.pb(-arr[i]);
		}
	}
	sort(all(v));
	if(k2>=v.size()) return sm;
	else
	{
		for(ll int i=0;i<v.size()-k2;i++)
		{
			sm-=v[i];
		}
		return sm;
	}
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
//	cin>>TESTS;
	while(TESTS--)
	{
		cin>>n>>k;
		for(ll int i=1;i<=n;i++) cin>>arr[i];
		ll int maxi=-1e18;
		for(ll int k1=0;k1<=k;k1++)
		{
			k1=k1;
			ll int k2=k-k1;
			for(ll int i=0;i<=n;i++)
			{
				for(ll int j=n+1;j>i;j--)
				{
					if(i<j)
					{
						maxi=max(maxi,fun(k1,k2,i,j));
					}
				}
			}
		}
		cout<<maxi;
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include <set>
#include<map>
#include <unordered_map>
#include <vector>

using namespace std;
const int N = 1e5+10;
typedef long long ll;
typedef  pair<ll,ll>PII;


int n;
string s1,s2,ans;

int main(){

        cin>>n;
        cin>>s1>>s2;
        for(int i=0;i<n;i++){
            ans+=s1[i];
            ans+=s2[i];
        }
        cout<<ans;

}

Measured memory_bytes: 256
#include <iostream>

int main()
{
	int r, g, b;
	std::cin >> r >> g >> b;

	int n = ( r * 100 + g * 10 + b );
	
	std::cout << ( n % 4 == 0 ? "YES" : "NO" ) << std::endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
template <class T> inline bool chmin(T &a, T b) {if (a > b){a = b;return true;}return false;}
template <class T> inline bool chmax(T &a, T b) {if (a < b){a = b;return true;}return false;}

int main(){
    int a,b,c; cin >> a >> b >> c;
    cout << max(0, c - (a-b)) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <algorithm>
#define ll long long
#define rep(i, a, b) for(int i = (a); i <= (b); i++)
using namespace std;
const int N = 1e5 + 9, M = 2e5 + 9;
const int inf = 0x3f3f3f3f;
int a[N], s[N], tr[M], n;
int lowbit(int x) { return x & (-x); }
void add(int x){ while(x < M) tr[x]++, x += lowbit(x); }
ll query(int x){
    ll res = 0;
    while(x > 0) res += tr[x], x -= lowbit(x);
    return res;
}
bool check(int x){
    ll res = 0;
    rep(i, 1, n) s[i] = s[i-1] + (a[i] >= x ? 1 : -1);
    memset(tr, 0, sizeof tr);
    rep(i, 0, n) res += query(s[i] + N), add(s[i] + N);
    return res * 2 >= 1ll * n * (n+1) / 2; 
}
int erfen(int l, int r){
    int res = 0;
    while(l <= r){
        int mid = (l + r) / 2;
        if(check(mid)) res = mid, l = mid+1;
        else r = mid-1;
    }
    return res;
}
int main(){
    int minn = inf, maxx = 0;
    scanf("%d", &n);
    rep(i, 1, n) {
        scanf("%d", &a[i]);
        maxx = max(maxx, a[i]), minn = min(minn, a[i]);
    }
    printf("%d", erfen(minn, maxx));
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <cstring>
#define MOD 924844033
using namespace std;
const int MAXN = 1<<21;
typedef long long ll;
int G,revG,n,k;
inline int ksm(int x,int k)
{
    int ret=1;
    while(k){
        if(k&1)ret=(ll)ret*x%MOD;
        x=(ll)x*x%MOD;
        k>>=1;
    }
    return ret;
}
inline void getG()
{
    for(int i=2;i<=MOD;++i)
        if(ksm(i,(MOD-1)/2)!=1 && ksm(i,(MOD-1)/3) && ksm(i,(MOD-1)/7)!=1){G=i,revG=ksm(G,MOD-2);return;}
}
struct NTT{
    int a[MAXN],w[MAXN],n;
    int safe(int x)
    {
        if(x>=MOD)x-=MOD;
        return x;
    }
    void ntt(int v)
    {
        for(int i=0,j=0;i<n;++i){
            if(i<j)swap(a[i],a[j]);
            for(int l=n>>1;(j^=l)<l;l>>=1);
        }
        w[0]=1;
        for(int i=2;i<=n;i<<=1){
            int g=v?ksm(revG,(MOD-1)/i):ksm(G,(MOD-1)/i);
            for(int j=(i>>1);j>=0;j-=2)w[j]=w[j>>1];
            for(int j=1;j<(i>>1);j+=2)w[j]=(ll)w[j-1]*g%MOD;
            for(int j=0;j<n;j+=i){
                int *p1=a+j,*p2=p1+(i>>1);
                for(int l=0;l<(i>>1);++l){
                    int o=(ll)w[l]*p2[l]%MOD;
                    p2[l]=safe(p1[l]-o+MOD);
                    p1[l]=safe(p1[l]+o);
                }
            }
        }
        if(v){
            int revn=ksm(n,MOD-2);
            for(int i=0;i<n;++i)a[i]=(ll)a[i]*revn%MOD;
        }
    }
}x,y;
int fac[4005],inv[4005];
inline void init()
{
    fac[0]=1;
    for(int i=1;i<=4000;++i)
        fac[i]=(ll)fac[i-1]*i%MOD;
    inv[4000]=ksm(fac[4000],MOD-2);
    for(int i=3999;i>=0;--i)
        inv[i]=(ll)inv[i+1]*(i+1)%MOD;
}
inline int C(int n,int m)
{
    return n>m?0:(ll)fac[m]*inv[m-n]%MOD*inv[n]%MOD;
}
inline void add(int &x,const int &a)
{
    x+=a;
    if(x>=MOD)x-=MOD;
}
int main()
{
    getG();
    init();
    scanf("%d%d",&n,&k);
    int len=1;
    while(len<(n+1))len<<=1;
    for(int i=0;i<=min((n-1)/k+1,n);++i){
        x.a[i]=C(i,(n-1)/k-i);
        y.a[i]=C(i,(n-1)/k-i+1);
    }
    x.n=y.n=len;
    x.ntt(0),y.ntt(0);
    int num2=(n%k==0?k:n%k),num1=k-num2;
    for(int i=0;i<len;++i)
        x.a[i]=(ll)ksm(x.a[i],num1*2)*ksm(y.a[i],num2*2)%MOD;
    x.ntt(1);
    int ans=0;
    for(int i=0,sta=1;i<=n;++i,sta=-sta)
        if(sta==1)add(ans,(ll)sta*x.a[i]*fac[n-i]%MOD);
        else add(ans,((ll)sta*x.a[i]+MOD)%MOD*fac[n-i]%MOD);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 6400
#include "bits/stdc++.h"
#pragma optimize("unroll-loops");
#pragma optimize("Ofast");
// #include "pch.h"    
using namespace std;

#ifdef DEBUG_BUILD
#  define DEBUG(x) cerr << x
#else
#  define DEBUG(x) do {} while (1)
#endif

#define imie(x) do { std::cerr << #x << ": " << x << std::endl; } while (0)

using ll = long long;
const ll nax = 1e7 + 10;
const int mod = 1e9 + 7;
vector<int> primes;

int abs(int a, int b) {
    if(a > b) {
        return a - b;
    }
    return b - a;
}

int main() {
    int n;
    scanf("%d", &n);
    unordered_map<int, int> here;
    vector<int> a(n);
    int cnt = 0;
    for(int& x : a) {
        scanf("%d", &x);
        if(here.count(x) == 0) {
            here[x] = 1;
        }else{
            here[x]++;
        }
        if(x == 1) {
            ++cnt;
        }
    }
    
    if(cnt > 1) {
        printf("0\n");
        return 0;
    }
    
    if(cnt == 1) {
        printf("1\n");
        return 0;
    }
    
    int ans = 0;
    for(int x : a) {
        bool ok = true;
        for(int i = 1; i * i <= x; ++i) {
            if(x%i == 0) {
                int div1 = i;
                int div2 = x/i;
                if(div2 == x) {
                    if((here.count(div2) && here[div2] - 1 > 0) || (here.count(div1))) {
                        ok = false;
                    }
                } else {
                    if(here.count(div1) || here.count(div2)) {
                        ok = false;
                    }
                }
                
                if(ok == false) {
                    break;
                }
            }
        }
        if(ok) {
            ++ans;
        }
    }
    
    printf("%d\n", ans);
    return 0;
}
                
                
                
                
                
                
                
                
                
                
                
                
                
                
                
                
                
                
                
                
                
                
                
                
                
                


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

using namespace std;

typedef long long ll;
const int flp=1e-6;
const int dflp=1e-12;
const int inf=2e9;
const int minf=-2e9;
const ll inf64=9e18;
const ll minf64=-9e18;

#ifdef WIN32
inline int getchar_unlocked()
{
    return _getchar_nolock();
}
inline void putchar_unlocked(char c)
{
    _putchar_nolock(c);
}
#endif

inline int raw_char()
{
    return getchar_unlocked();
}

inline int read_char()
{
    char c;
    do
    {
        c=getchar_unlocked();
    } while(c<33);
    return c;
}

inline void print_char(char c)
{
    putchar_unlocked(c);
}

template<typename T=ll>
inline T read_int()
{
    T temp=0;
    bool neg=0;
    char c=read_char();
    if(c=='-')
    {
        neg=1;
        c=raw_char();
    }
    while(c>='0'&&c<='9')
    {
        temp=temp*10+c-'0';
        c=raw_char();
    }
    return neg?-temp:temp;
}

template<typename T=ll>
inline void print_int(T x)
{
    if(x==0)
    {
        print_char('0');
        return;
    }
    char buff[24];
    int idx=0;
    if(x<0)
    {
        print_char('-');
        x=-x;
    }
    while(x)
    {
        buff[idx++]=x%10+'0';
        x/=10;
    }
    while(idx)
        print_char(buff[--idx]);
}

inline void read_str(std::string &s,char delim='\n',bool skip_whtspc=0,int bufsize=8192)
{
    char t[bufsize],c;
    if(skip_whtspc)
        c=read_char();
    else
        c=raw_char();
    int idx=0;
    while(c!=delim)
    {
        t[idx++]=c;
        c=raw_char();
    }
    t[idx]=0;
    raw_char();
    s=t;
}

inline void read_cstr(char *s,char delim='\n',bool skip_whtspc=0)
{
    char c;
    if(skip_whtspc)
        c=read_char();
    else
        c=raw_char();
    int idx=0;
    while(c!=delim)
    {
        s[idx++]=c;
        c=raw_char();
    }
    s[idx]=0;
    raw_char();
}

inline void print_str(std::string s)
{
    int len=s.length();
    for(int i=0;i<len;++i)
        print_char(i);
}

inline void print_cstr(const char *s)
{
    while(*s)
        print_char(*s++);
}

ll pow(int a,int b,ll m=inf64)
{
    ll ret=1;
    while(b)
        if(b&1)
        {
            ret*=a;
            --b;
        }
        else
        {
            b>>=1;
            ret*=ret;
        }
    return ret;
}

ll gcd(ll a,ll b)
{
    while(b)
    {
        ll t=a;
        a=b;
        b=a%b;
    }
    return a;
}

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

template<typename T>
int fcmp(T a,T b,T eps)
{
    T t=a-b;
    if(abs(t)<=eps)
        return 0;
    if(t>=-eps)
        return 1;
    return -1;
}

int main()
{
    int n=read_int(),k=read_int();
    vector<int> x(n);
    for(auto &i:x)
        i=read_int();
    vector<ll> dp(n,inf);
    dp[0]=0;
    for(int i=0;i<n;++i)
        for(int j=1;j<=k&&i+j<n;++j)
            dp[i+j]=min(dp[i+j],dp[i]+abs(x[i]-x[i+j]));
//    for(auto &i:dp)
//    {
//        print_int(i);
//        if(&i!=&dp.back())
//            print_char(' ');
//    }
//    print_char('\n');
    print_int(dp[n-1]);
    print_char('\n');
    return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define endl "\n"
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define B begin()
#define E end()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<ll> VL;
typedef set<ll> SL;
typedef pair<ll, ll> p2;
const ll M = 1000000007;
const ll M2= 998244353;

void solve()
{
	ll x, y; cin>>x>>y;
	for(int i=0;i<=x;i++)
	{
		if(y==2*i+4*(x-i))
		{
			cout<<"Yes"<< endl;
			return;
		}
	}
	cout<<"No"<<endl;	
}
 
int main()
{
    IOS
    int _=1;
    //cin>>_;
    while(_--)
    {
	    solve();
    }
    
    return 0;
}


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

using namespace std;

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

    vector<int> num(9);
    for (int i = 0; i < N; i++) {
        int a;
        cin >> a;

        if (a < 3200) num[a/400]++;
        else num[8]++;
    }

    int min = 0;
    for (int i = 0; i < 8; i++) {
        if (num[i] > 0) {
            min++;
        }
    }

    int max = min + num[8];
    if (min == 0) min++;

    cout << min << ' ' << max << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>

int main(){
	int a,b;
	char c;
	scanf("%d %c %d", &a, &c, &b);
	while(c != '?'){
		if(c == '+'){
			printf("%d\n", a + b);
		}else if(c == '-'){
			printf("%d\n", a - b);
		}else if(c == '*'){
			printf("%d\n", a * b);
		}else{
			printf("%d\n", a / b);
		}
		scanf("%d %c %d", &a, &c, &b);
	}
	return 0;
}

Measured memory_bytes: 1028
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		sc.close();

		int ans = Integer.MAX_VALUE;
		for (int i = 0; i <= n; i++) {
			int cnt = 0;
			int n6 = i;
			int n9 = n - i;

			for (int a = 6; a >= 0; a--) {
				int mod = (int) Math.pow(6, a);
				cnt += n6 / mod;
				n6 %= mod;
			}
			for (int a = 5; a >= 0; a--) {
				int mod = (int) Math.pow(9, a);
				cnt += n9 / mod;
				n9 %= mod;
			}
			ans = Math.min(ans, cnt);
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 25172
#include <bits/stdc++.h>
#define i_love_u_Phuong ios_base::sync_with_stdio(0); cin.tie(0);


using ll = long long;
using namespace std;
using ld = long double;



struct point
{
    int x,y;
};



int main()
{
#ifndef ONLINE_JUDGE
    //freopen("input.txt", "r", stdin);
#endif // ONLINE_JUDGE
    i_love_u_Phuong;
    int n;
    int y;
    cin >> n >> y;
    priority_queue<int> pq;
    for(int i=0; i<n; ++i)
    {
        int k;
        cin >> k;
        pq.push(k);
    }
    for(int i=0; i<y; ++i)
    {
        int u=pq.top();
        if (u==0) break;
        pq.pop();
        u>>=1;
        pq.push(u);
    }
    ll sum=0;
    while(!pq.empty())
    {
        sum+=int64_t(pq.top());
        pq.pop();
    }
    cout << sum;
    return 0;
}



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

using namespace std;

int n;
int a[200005];

int main()
{
    //freopen ("Lee.inp", "r", stdin);
    //freopen ("Lee.out", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin >> n;
    for (int i = 1; i <= n; i++)
        cin >> a[i];
    sort (a + 1, a + 1 + n);
    a[0] = 2582004;
    for (int i = 1; i <= n; i++)
        if (a[i] == a[i - 1])
            return cout << "NO", 0;
    cout << "YES";
}


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


int main() {
  int N;
  scanf("%d", &N);
  
  int t[N], x[N], y[N];
  for (int i=0; i<N; i++){
  	scanf("%d%d%d", &t[i], &x[i], &y[i]);
  }
  
  bool u=true;
  for (int i=0; i<N;i++){
  	if (i==0) {
    	if (abs(x[0])+abs(y[0])>t[0]) u=false;
    }
    else {
    	if (abs(x[i]-x[i-1])+abs(y[i]-y[i-1])>t[i]-t[i-1]) u=false;
    }
  }

  bool s=true;
  for (int i=0; i<N && s;i++){
    if (t[i]%2 != (x[i]+y[i])%2) s=false;
   }

	if (s&&u) cout << "Yes" << endl;
	else cout <<"No" <<endl;
}


Measured memory_bytes: 1408
val1 = input().split()
val2 = input().split()
total = 0
for votes in val2:
  total += int(votes)
thres = total * 1/4 / int(val1[1]) 
i = 0
for votes in val2:
  if int(votes) >= thres:
    i += 1
if i >= int(val1[1]):
  print("Yes")
else:
  print("No")


Measured memory_bytes: 3060
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

void main() {
    readint;
    auto ss = reads!string;

    bool[string] d;
    foreach (s; ss) d[s] = true;
    writeln(d.keys.length == 3 ? "Three" : "Four");
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;++i)

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

ll INF=1e10;

//メモ化再帰で解く
ll dp[100010];
ll h[100010];
ll rec(int i){
  if(dp[i] < INF)return dp[i];
  if(i==0)return 0;
  ll res=INF;
  chmin(res,rec(i-1)+abs(h[i]-h[i-1]));
  if(i>1)chmin(res,rec(i-2)+abs(h[i]-h[i-2]));
  return dp[i]=res;
}

int main(){
  ll n;
  cin >> n;
  rep(i,100010)dp[i]=INF;
  rep(i,n)cin >> h[i];
  cout << rec(n-1) << endl;
}


Measured memory_bytes: 6528
/* ****AWARE**** */
#include<bits/stdc++.h>
#include <limits.h> 
#define cut ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll          long long
#define pb          push_back
#define endl        '\n'
#define pii         pair< ll, ll>
#define vi          vector< ll>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll)x.size()
#define hell        1000000007
#define rep(i,a,b)  for(  ll i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp13       make_pair
using namespace std; 
#define MAX  3000
#define MODULO 2
using namespace std;   
#define hell 1000000007 
#define hell1 30000000000000000
#define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
#define mysizeof(i) (char*)(&i+1)-(char *)(&i);
ll T;
char v[MAX][MAX];
ll mx=1;
ll dp[MAX][MAX];

ll dfs(int i,int j,int n,int m)
{   int a=0,b=0,ans;
     if(i==n-1 && j==m-1)
     {
     	return 1;
     }

    if(i+1<n && v[i+1][j]=='.')
  	{  if(dp[i+1][j]==-1)
  		a=dfs(i+1,j,n,m)%hell;
  		else
  		a=dp[i+1][j];
  	}
  	if(j+1<m && v[i][j+1]=='.')
  	{   if(dp[i][j+1]==-1)
  		b=dfs(i,j+1,n,m)%hell;
  		else
  		b=dp[i][j+1];
  	}
    if(a==0)
   	return dp[i][j]=b;
    else if(b==0)
   	return dp[i][j]=a;
    else
   	return dp[i][j]=((a+ b)%hell);

}
void solve()
{  ll i,j,k,n,m,b;
	char a;
    cin>>n>>m;
    for(i=0;i<n;i++)
    {
     for(j=0;j<m;j++)
      {
     	 cin>>a;
    	  v[i][j]=a;
    	  dp[i][j]=-1;
      }
    }
     cout<<dfs(0,0,n,m)<<"\n";
    

}
           
int main(){ 
cut; 
ll t; 
//cin>>t;
//T=t;
 t=1;
while(t--)
solve();
return 0;
}
     


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

int main()
{
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  if(a + b > c + d)
  {
    cout << "Left" << endl;
  }
  else if(a + b < c + d)
  {
    cout << "Right" << endl;
  }
  else
  {
    cout << "Balanced" << endl;
  }
}

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

int N, M;
char arr[110];

int main(){
	int i;
	scanf("%s %d", arr, &M); N = strlen(arr);
	for(i = 0; i < N; i++){
		if(i == M - 1) break;
		if(arr[i] != '1'){
			printf("%c", arr[i]); return 0;
		}
	}
	printf("%c", arr[i]);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define ll long long int
#define INF 1000000007
#define llINF 1000000000000000007
// cin.eof() 入力個数の問題
// int num = atoi(string.c_str()); 文字列の整数変換
 
int main() {
  string s;
  cin>>s;
  ll ans=0;
  int n=s.size()-1;
for(int bit=0;bit < (1<<n);++bit){
    string S=s;
for(int i = 0; i < n ;i++){
    int g=2*(i+1)-1;
if(bit&(1<<i)){
    S.insert(g,"+");
}else
{
    S.insert(g,"0");
}
}
ll count=0;
for(int i=0;i<S.size();i++){
if(S[i]=='0') continue;
else if(S[i]=='+'){
    ans+=count;
    count=0;
}else
{
    count*=10;
    count+=S[i]-'0';
}
//cout<<ans<<endl;
}
ans+=count;
count=0;
//cout<<S<<endl;
//cout<<ans<<endl;

}
cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3608
// Aizu 1147: ICPC Score Totalizer Software
// 2017.9.13 bal4u@uu

#include <stdio.h>

int main()
{
	int n, a, i, sum, min, max;

	while (scanf("%d", &n) && n) {
		for (min = 1001, max = -1, sum = 0, i = 0; i < n; i++) {
			scanf("%d", &a);
			if (a < min) min = a;
			if (a > max) max = a;
			sum += a;
		}
		printf("%d\n", (sum - min - max)/(n-2));
	}
	return 0;
}

Measured memory_bytes: 1772
from operator import mul
from functools import reduce

def factorial(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom

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

if n < 2:
    ans_1 = 0
else:
    ans_1 = factorial(n, 2)
if m < 2:
    ans_2 = 0
else:
    ans_2 = factorial(m, 2)
print(ans_1+ans_2)

Measured memory_bytes: 38256
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

int main(void) {
    string s;
    cin >> s;
    int ue = (s[0] - '0') * 10 + (s[1] - '0');
    int sita = (s[2] - '0') * 10 + (s[3] - '0');

    bool is_sy=false, is_uy=false, is_sm=false, is_um=false;

    if (0 <= ue && ue <= 99) is_uy = true;
    if (1 <= ue && ue <= 12) is_um = true;
    if (0 <= sita && sita <= 99) is_sy = true;
    if (1 <= sita && sita <= 12) is_sm = true;

    if (is_sy && is_sm && is_uy && is_um) cout << "AMBIGUOUS" << endl;
    else if (is_uy && is_sm) cout << "YYMM" << endl;
    else if (is_um && is_sy) cout << "MMYY" << endl;
    else cout << "NA" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a[101],n,ans=1;
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	sort(a+1,a+n+1);
	for(int i=2;i<=n;i++)
		if(a[i]!=a[i-1])
			ans++;
	cout<<ans;
	return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>   
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll mod = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
     
ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * B / gcd(A, B);
}
template <typename T>
T pow(T a, ll n, T e = 1) {
    T ret = e;
    while (n) {
        if (n & 1) ret *= a;
        a *= a;
        n >>= 1;
    }
    return ret;
}
 
template <int mod>
struct ModInt {
    int x;
    ModInt() : x(0) {}
    ModInt(long long x_) {
        if ((x = x_ % mod + mod) >= mod) x -= mod;
    }
    ModInt& operator+=(ModInt rhs) {
        if ((x += rhs.x) >= mod) x -= mod;
        return *this;
    }
    ModInt& operator-=(ModInt rhs) {
        if ((x -= rhs.x) < 0) x += mod;
        return *this;
    }
    ModInt& operator*=(ModInt rhs) {
        x = (unsigned long long)x * rhs.x % mod;
        return *this;
    }
    ModInt& operator/=(ModInt rhs) {
        x = (unsigned long long)x * rhs.inv().x % mod;
        return *this;
    }
 
    ModInt operator-() const { return -x < 0 ? mod - x : -x; }
    ModInt operator+(ModInt rhs) const { return ModInt(*this) += rhs; }
    ModInt operator-(ModInt rhs) const { return ModInt(*this) -= rhs; }
    ModInt operator*(ModInt rhs) const { return ModInt(*this) *= rhs; }
    ModInt operator/(ModInt rhs) const { return ModInt(*this) /= rhs; }
    bool operator==(ModInt rhs) const { return x == rhs.x; }
    bool operator!=(ModInt rhs) const { return x != rhs.x; }
    ModInt inv() const { return pow(*this, mod - 2); }
 
    friend ostream& operator<<(ostream& s, ModInt<mod> a) {
        s << a.x;
        return s;
    }
    friend istream& operator>>(istream& s, ModInt<mod>& a) {
        s >> a.x;
        return s;
    }
};
 
using mint = ModInt<1000000007>;
using Graph = vector<vector<int>>;
Graph G;
/*------------------------------------------------------------------*/
 
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
 
    string s; cin >> s;
    int m = s.size();
    string t = "ATGC";

    int i = 0;
    int ans = 0;
    while(i < m){
        int len = 0;
        if(s[i] == 'A' or s[i] == 'T' or s[i] == 'G' or s[i] == 'C'){
            while(i < m and s[i] == 'A' or s[i] == 'T' or s[i] == 'G' or s[i] == 'C'){
                i++;
                len++;
            }
        }else i++;
        ans = max(len, ans);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3604
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

using ll = long long;
using ull = uint64_t;
using P = pair<int, int>;
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

template<class T>
inline bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

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

    int K;
    cin >> K;
    map<ll, ll> mp;
    ll bound = 1e+15;
    ll mul = 1;
    for(int d = 0; d < 15; ++d){
        for(int i = 1; i < 150; ++i){
            ll val = mul * (i + 1) - 1;
            if(val > bound) break;
            ll S = 0;
            ll X = val;
            while(X > 0){
                S += X % 10;
                X /= 10;
            }
            mp[val] = S;
        }
        mul *= 10;
    }
    while(K > 0){
        bool ok = true;
        ll val = -1, S = -1;
        for(auto it : mp){
            if(val == -1){
                val = it.first, S = it.second;
            }
            else{
                if(val * it.second > it.first * S){
                    ok = false;
                    break;
                }
            }
        }
        if(ok){
            cout << val << '\n';
            --K;
        }
        mp.erase(val);
    }
}

Measured memory_bytes: 3736
use proconio::input;

#[allow(unused_imports)]
use proconio::marker::{Bytes, Chars, Usize1};
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::ops::*;

#[derive(Clone, Debug, Default)]
struct Struct;

//#[proconio::fastout]
fn main() {
    input! {
        a: u64,
        b: u64,
        n: u64,
    }

    if b-1 <= n {
        // x = b-1
        println!("{}", (a*(b-1))/b);
                
    } else {
        // x = n
        println!("{}", (a*n)/b);
    }
}


Measured memory_bytes: 2104
import sys
import math
import itertools

s=int(input())
ans=[]
count=0
while True:
	count+=1
	if s in ans:
		print(count)
		sys.exit()
	ans.append(s)
	if s%2==0:
		s=int(s/2)
	else:
		s=int(s*3+1)







Measured memory_bytes: 3060
import java.util.*;
// warm-up
public class Main {

	static class Kitana implements Comparable<Kitana> {
		int d=0, i=0; // Damage, index
		boolean w = false;
		Kitana (int a, boolean t) {
			d=a; w=t;
		}
		public int compareTo (Kitana other) {
			return other.d-d;
		}
		public String toString() {
			return "Damage: "+d+" Wield: "+w;
		}
	}

	static void solve() {
		Scanner sc = new Scanner(System.in);
		List<Kitana> k = new ArrayList<Kitana>();
		int N = sc.nextInt(), H = sc.nextInt(), D = 0, t = 0, c = 0;
		while (N-->0) {
			k.add(new Kitana(sc.nextInt(), true));
			k.add(new Kitana(sc.nextInt(), false));
		}
		Collections.sort(k);
		for (Kitana o : k) {
			if (!o.w) { t+=o.d; c++; }
			if (t>=H) break;
			if (o.w) {
				c+=(H-t)%o.d==0 ? (H-t)/o.d : (H-t)<o.d ? 1 : ((H-t)/o.d)+1; 
				break;
			}
		}
		System.out.println(c);
		sc.close();		
	}

	public static void main(String args[]) {
		solve();
	}

}

Measured memory_bytes: 68696
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
using namespace std;
typedef long long ll;

int main(){
    int p,r,t;
    cin >> p >> r >> t;
    vector<int> l(r);
    for(int i=0;i<r;i++){
        cin >> l[i];
    }
    vector<vector<int> > n(p,vector<int>(r));
    for(int i=0;i<p;i++){
        for(int j=0;j<r;j++){
            cin >> n[i][j];
        }
    }
    vector<int> P(t),R(t);
    for(int i=0;i<t;i++){
        cin >> P[i] >> R[i];
        P[i]--;
        R[i]--;
    }
    int ok = -1;
    int ng = t+1;
    while(abs(ok-ng)!=1){
        int mid = (ok+ng)/2;
        //cout << mid << endl;
        vector<int> x(r);
        vector<vector<int> > y(p,vector<int>(r));
        for(int i=0;i<r;i++){
            x[i] = l[i];
        }
        for(int i=0;i<p;i++){
            for(int j=0;j<r;j++){
                y[i][j] = n[i][j];
            }
        }
        for(int i=0;i<mid;i++){
            x[R[i]]--;
            y[P[i]][R[i]]--;
            if(y[P[i]][R[i]]==0){
                bool flag = 1;
                for(int j=0;j<r;j++){
                    if(y[P[i]][j]!=0){
                        flag = 0;
                        break;
                    }
                }
                if(flag){
                    for(int j=0;j<r;j++){
                        y[P[i]][j]=n[P[i]][j];
                        x[j] += n[P[i]][j];
                    }
                }
            }
        }
        vector<bool> sss(p);
        for(int z=0;z<p;z++){
            for(int i=0;i<p;i++){
                if(sss[i]==1)continue;
                bool flag = 1;
                for(int k=0;k<r;k++){
                    //cout << i << " " << k << " " << y[i][k] << " " <<x[k] << endl;
                    if(y[i][k]>x[k]){
                        flag=0;
                        break;
                    }
                }
                if(flag){
                    sss[i]=1;
                    for(int k=0;k<r;k++){
                        x[k] += n[i][k]-y[i][k];
                    }
                }
            }
        }
        bool flag = 1;
        for(int i=0;i<p;i++){
            if(sss[i]==0){
                flag = 0;
            }
        }
        if(flag){
            ok = mid;
        }else{
            ng = mid;
        }
    }
    if(ng==t+1){
        cout << -1 << endl;
    }else{
    cout << ng << endl;
    }
    return 0;
}


Measured memory_bytes: 5188
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD=1000000007;
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)

int main(void){
    int n,m;
    cin>>n>>m;
    Graph F(n);
    rep(i,m){
        int a,b;
        cin>>a>>b;
        a--,b--;
        F[a].push_back(b);
        F[b].push_back(a);
    }
    vector<int> seen(n,-1);
    queue<int> que;
    int group=0,max_member=0;
    rep(i,n){
        if(seen[i]!=-1) continue;
        seen[i]=group;
        que.push(i);
        int temp=1;
        while(!que.empty()){
            int u=que.front();
            que.pop();
            for(auto v:F[u]){
                if(seen[v]!=-1) continue;
                seen[v]=seen[u];
                que.push(v);
                temp++;
            }
        }
        //cout<<group<<" "<<temp<<endl;
        group++;
        chmax(max_member,temp);
    }
    cout<<max_member<<endl;
    return 0;
}

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

int main(){
  int A,B,C,X;
  cin >> A >> B >> C >> X;
  int ans = 0;
  rep(i, A){
    rep(j, B){
      rep(k, C){
        int kin = 500 * i + 100 * j + 50 * k;
        if(kin == X){
          ans++;
        }
      }
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    int ans = 0;
    rep(i,100) {
        if(a <= i && i < b && c <= i && i < d) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
using namespace std;
typedef struct {
	int p,q;
}pai;
int compare(const void* a,const void *b){
	pai s=*(pai*)a,t=*(pai*)b;
	return -s.q+t.q;
}
int main(){
	pai pa[500];
	int x,y,k=0;
	while(scanf("%d,%d",&x,&y),x||y){
		pa[k].p=x;
		pa[k++].q=y;
	}
	qsort(pa,k,sizeof(pai),compare);
	int r,ran=1,s[500];
	int pre=pa[0].q;
	for(int i=0;i<k;i++){
	if(pre==pa[i].q)
	s[pa[i].p]=ran;
		else{
			s[pa[i].p]=++ran;
			pre=pa[i].q;
		}
	}
	
	while(cin>>r){
		cout<<s[r]<<endl;
	}
	return 0;
}

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

int main() {
  int x; cin >>x;
  bool end = false;
  int i=0;
  
  while(!end){
    if(i*(i+1)/2 >= x){
      end = true;
      break;
    }
    i++;
  }
  cout <<i <<endl;
  
  //if (ans) cout <<"YES" <<endl;
  //else cout <<"NO" <<endl;
  
}


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

int n,a[200000],sm1[200000],sm2[200000],x1[200000],x2[200000];

signed main(){
 
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a[i],sm1[i]=a[i],sm2[i]=a[i];
  }

  for(int i=1;i<n;i++)sm1[i]+=sm1[i-1];
  for(int i=n-2;i>=0;i--)sm2[i]+=sm2[i+1];
  
  for(int i=n-1;i>=0;i--){
    int y=(i+1<n?x1[i+1]:0);
    if(a[i]==0)x1[i]=min(y+2,sm2[i]);
    else x1[i]=min(y+a[i]%2,sm2[i]);
  }

  for(int i=0;i<n;i++){
    int y=(i-1>=0?x2[i-1]:0);
    if(a[i]==0)x2[i]=min(y+2,sm1[i]);
    else x2[i]=min(y+a[i]%2,sm1[i]);
  }
  
  int ans=1e9,c=0;

  for(int i=0;i<n;i++){
    ans=min(ans,x1[i]+c);
    if(a[i]%2==0)c=min(c+1,x2[i]);
  }
  ans=min(ans,c);

  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 8064
def check(st,count):
    flag = False
    new_list = []
    for i in st:
        if i % 2 == 0:
            i = i // 2
            new_list.append(i)
        else:
            flag = True
            break
    if flag:
        print(count)
        return
    else:
      count += 1
      check(new_list, count)

n = int(input())
st = list(map(int, input().split()))
count = 0
check(st, count)



Measured memory_bytes: 3188
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "" : " ");
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N;
	cin >> N;

	vector<lint> A(N);
	map<lint, queue<int>> mp;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		mp[A[i]].emplace(i);
	}
	sort(A.begin(), A.end(), greater<lint>());

	int ans = 0;
	for (int i = 0; i < N; i++) {

		if (mp[A[i]].empty()) continue;
		mp[A[i]].pop();

		for (int j = 0; j < 32; j++) {
			lint tmp = (1LL << j) - A[i];
			if (mp.find(tmp) != mp.end()) {
				if (!mp[tmp].empty()) {
					mp[tmp].pop();
					ans++;
				}
			}
		}

	}

	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 145536
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int book[10]={0};
int check(int b){
	int flag=1;
	while(b!=0){
		if(book[b%10]==1) flag++;
		b=b/10;
	}
	return flag;
}
int main(){
	int n,b,I;
	cin>>b>>n;
	for(int i=0;i<n;i++){
		cin>>I;
		book[I]=1;
	}
	while(1){
		if(check(b)==1) break;
		b++;
	}
	cout<<b;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(v, a, b) for(int v = (a); v < (b); ++v)
#define FORE(v, a, b) for(int v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(int v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define LLI long long int
#define fst first
#define snd second
#ifdef DEBUG
#include <boost/core/demangle.hpp>
#define dump(x) cerr << "L" << __LINE__ << ": in " << __PRETTY_FUNCTION__ << " \e[32;1m" << boost::core::demangle(typeid(x).name()) << "\e[37m" << " " << (#x) << " = " << (x) << "\e[m" << endl;
#else
#define dump(x)
#endif
using namespace std;
template <typename T> using V = vector<T>;
template <typename T, typename U> using P = pair<T,U>;
template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}
template <typename T, typename U> istream& operator>>(istream &is, pair<T,U> &p){is >> p.first >> p.second; return is;}

template <typename T> ostream& operator<<(ostream &os, vector<T> &v){os << "{";ITR(i,v){if(i!=v.begin())os << ","; os << *i;}os << "}"; return os;}
template <typename T, typename U> ostream& operator<<(ostream& os, pair<T,U> &p){os << "(" << p.first << "," << p.second << ")"; return os;}

template <typename T> T& chmin(T &a, const T &b){return a = min(a,b);}
template <typename T> T& chmax(T &a, const T &b){return a = max(a,b);}

const LLI mod = 1e9+7;

LLI dp[110][101000];

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

  int N,K; cin >> N >> K;
  vector<int> a(N); cin >> a;

  dp[0][0] = 1;

  REP(i,N){
    vector<LLI> sum(K+2, 0);
    REPE(j,K) (sum[j+1] = sum[j] + dp[i][j]) %= mod;
    REPE(j,K){
      (dp[i+1][j] = sum[j+1] - sum[max(j-a[i], 0)] + mod) %= mod;
    }
  }

  cout << dp[N][K] << endl;
  
  return 0;
}


Measured memory_bytes: 80124
# -*- coding: utf-8 -*-
#ARC099C
import sys

#n= int(input())
tmp = input().split()
n,k = list(map(lambda a: int(a), tmp))

tmp = input().split()
s = list(map(lambda a: int(a), tmp))

pos=tmp.index("1")
#print(tmp)
#print(tmp.index("1"))
#print(((pos)//k)+1)
#print(((n-pos-1)//k)+1)

if(k!=n):
	print((n-2)//(k-1)+1)
	#print(((pos)//k)+1+((n-pos-1)//k)+1)
else:
	print(1)


Measured memory_bytes: 14008
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int,int> P;

int main(){
	ll n,a,b;
	cin>>n>>a>>b;
	ll p=a+b;
	ll num=n/p;
	ll res=n-num*p;
	if(res>=a)cout<<num*a+a<<endl;
	else cout<<num*a+res<<endl;
	return 0;
}


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

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

int main() {
	int n;
	cin >> n;
	while (n--) {
		int h, m;
		scanf("%d:%d", &h, &m);
		
		double angle1 = m * 6.0, angle2 = h * 30.0 + m / 2.0;
		double div = min(abs(angle1 - angle2), 360.0 - abs(angle1 - angle2));
		
		if (div >= 0 && div < 30.0)
			puts("alert");
		else if (div >= 90.0 && div <= 180.0)
			puts("safe");
		else
			puts("warning");
	}
	return 0;
}

Measured memory_bytes: 1200
#include<iostream>
#include<map>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
using namespace std;
int main(){
	int n;
	while(1){
		cin >> n;
		if(n==0) break;
		int sum,hoge=n;
		n<2?sum=0:sum=1;
		for(int i=2;i< hoge && sum < n;i++){
			if(n%i == 0){      //約数
				hoge= n/i;     //n = i * hoge
				if(i!=hoge){   
					sum += i+hoge;
				}else{
					sum += i;
				}
			}
		}
	if(sum==n)
		cout << "perfect number" << endl;
	else if(sum < n)
		cout << "deficient number" << endl;
	else
		cout << "abundant number" << endl;
	}
}

Measured memory_bytes: 1156
#include <iostream>
#include <limits.h>
#define REP(i, n) for(int i = 0; i < (int)(n); i++)

using namespace std;
int main() {
    int n;
    int ans = INT_MIN;
    int prev;
    int current;
    int vtmp = 0;
    cin >> n;
    cin >> prev;
    REP(i, n - 1){
        cin >> current;
        int tmp = current - prev;
        vtmp += tmp;
        if ((tmp >= ans) && (ans < 0)){
            ans = tmp;
            vtmp = ans;
        }
        else if (vtmp >=ans)
        {
            ans = vtmp;
        }
        else if (vtmp < 0)
        {
            vtmp = 0;
        }
        

        prev = current;
        
    }
    cout << ans << endl;
    return 0;
}




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

main(){
  int i,flag=0;
  char c;
  vector<char> vow={'a','e','i','o','u'};
  cin >> c;
  for(i=0;i<5;i++){
    if(c==vow[i]) {
      flag = 1;
      break;
    }
  }
  if(flag) cout << "vowel" << endl;
  else cout << "consonant" << endl;
}

Measured memory_bytes: 256
// This file is a "Hello, world!" in C++ language by GCC for wandbox.
#include <iostream>
#include <cstdlib>
using namespace std;
int main()
{   
   int x,a;
    cin>>x>>a;
    if(x<a){
    cout<<0<<endl;
    }else if(x>=a){
    cout<<10<<endl;
    }
 }
 
    
    

// GCC reference:
//   https://gcc.gnu.org/

// C++ language references:
//   https://cppreference.com/
//   https://isocpp.org/
//   http://www.open-std.org/jtc1/sc22/wg21/

// Boost libraries references:
//   https://www.boost.org/doc/




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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


typedef complex<double> P;
const double PI = acos(-1.0);
const double EPS = 1e-10;

inline double dot(P a, P b) {return real(conj(a)*b);}
inline double cross(P a, P b) {return imag(conj(a)*b);}
inline int signum(double x) {return x > EPS ? +1 : x < -EPS ? -1 : 0;}

namespace std {
  bool operator < (const P& a, const P& b) {
    return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
  }
}


int ccw(P a, P b, P c) {
  // return signum(cross(b - a, c - a));
  b -= a; c -= a;
  if (cross(b, c) > 0)   return +1;       // counter clockwise
  if (cross(b, c) < 0)   return -1;       // clockwise
  if (dot(b, c) < 0)     return +2;       // c--a--b on line
  if (norm(b) < norm(c)) return -2;       // a--b--c on line
  return 0;
}

vector<P> convexHull(vector<P> ps){
  int N = (int)ps.size();
  int k = 0;
  sort(ps.begin() , ps.end());
  vector<P> ch(2 * N);
  for(int i=0; i < N; ch[k++] = ps[i++] )
    while( k >= 2 && ccw( ch[k-2] , ch[k-1], ps[i] ) <= 0 ) --k;  
  for(int i= N-2, t = k+1; i >= 0; ch[k++] = ps[i--] )
    while( k >= t && ccw( ch[k-2] , ch[k-1] , ps[i] ) <= 0 ) --k;
  ch.resize(k-1);
  return ch;
}

// (-PI, PI]
double arg(P a, P b) { return arg(conj(a)*b); }

int main2() {
  int N; cin >> N;
  vector<double> ans(N);

  vector<P> org;
  REP(i, N) {
    double x, y; cin >> x >> y;
    org.push_back(P(x, y));
  }
  vector<P> ps = convexHull(org);
  // pv(ALL(ps));

  if (ps.size() <= 2) {
    REP(i, N) {
      REP(j, ps.size()) {
        if (norm(org[i] - ps[j]) <= EPS) {
          ans[i] = 1.0 / ps.size();
        }
      }
    }
    REP(i, N) {
      printf("%.8f\n", ans[i]);
    }
    return 0;
  }

  vector<double> ps_ans(ps.size());
  REP(i0, ps.size()) {
    int i1 = (i0 + 1) % ps.size();
    int i2 = (i0 + 2) % ps.size();
    P v1 = ps[i1] - ps[i0];
    P u1 = v1 * P(0, 1);
    P v2 = ps[i2] - ps[i1];
    P u2 = v2 * P(0, 1);
    double t = arg(u1, u2);
    // cout << u1 << " "<< u2 << " " << t << endl;
    ps_ans[i1] = t >= 0 ? t : PI+t;
  }

  // {
    // double sum = 0;
    // REP(i, ps.size()) sum += ps_ans[i];
    // if (abs(sum - 2*PI) > EPS) for(;;);
  // }

  REP(i, ps.size()) ps_ans[i] /= 2 * PI;

  // cout << "ps_ans=" << endl;
  // REP(j, ps.size()) {
    // cout << ps_ans[j] << endl;
  // }
  REP(i, N) {
    REP(j, ps.size()) {
      if (norm(org[i] - ps[j]) <= EPS) {
        ans[i] = ps_ans[j];
      }
    }
  }

  REP(i, N) {
    printf("%.10f\n", ans[i]);
  }
  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws)
    main2();
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    String S = sc.next();
    int max = 0;
    int x = 0;
    for(int i = 0; i < S.length(); i++) {
      if(S.charAt(i) == 'I') {
        x += 1;
      } else {
        x -= 1;
      }
      max = Math.max(max, x);
    }
    System.out.println(max);
  }
}

Measured memory_bytes: 9680
def calMinkowski(n,x,y,p)
    d = 0
    max = 0
    n.times do |i|
        abs = (x[i]-y[i]).abs.to_f
        max = abs if max < abs
        d += abs**p
    end
    if p == -1 then
        max
    else
        d = d**(1/p.to_f)
    end
end
n = gets.to_i
x = gets.split.map(&:to_i)
y = gets.split.map(&:to_i)

puts calMinkowski(n,x,y,1)
puts calMinkowski(n,x,y,2)
puts calMinkowski(n,x,y,3)
puts calMinkowski(n,x,y,-1)


Measured memory_bytes: 8920
#include <bits/stdc++.h>
#define ll long long
#define rep(i, n) for (int i=0; i<n; i++)
 
using namespace std;
const double PI = acos(-1);
using Graph = vector<vector<int>>;
 
int main() {
	int h, w, k;
	cin >> h >> w >> k;
	char c[h][w];
	char d[h][w];
	rep(i, h)
	{
		rep(j, w)
		{
			char x;
			cin >> x;
			c[i][j] = x;
			d[i][j] = x;
		}
	}
	int ret = 0;
	for (int b1 = 0; b1 < (1<<h); b1++)
	{
		for (int b2 = 0; b2 < (1<<w); b2++)
		{
			for (int i = 0; i < h; i++)
			{
				for (int j = 0; j < w; j++)
				{
					if (b1 & (1<<i))
					{
						rep(k, w) d[i][k] = 'r';
					}
					if (b2 & (1<<j))
					{
						rep(l, h) d[l][j] = 'r';
					}
				}
			}

			int count = 0;
			rep(i, h)
			{
				rep(j, w)
				{
					if (d[i][j] == '#')
						count++;
				}
			}
			if (count == k)
				ret++;
			rep(i, h)
			{
				rep(j, w)
				{
					d[i][j] = c[i][j];
				}
			}	
		}
	}
	cout << ret << endl;
}

Measured memory_bytes: 3628
//Nihal Mittal - nihal_47
//Strike First , Strike Hard , No Mercy !!

/**⠀⠀⠀⠀⠀⠀⣀⣤⣤⣄⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⣠⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣦⣀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⣰⣿⣿⣿⣿⠿⠿⣿⣿⣿⣿⣿⣿⣿⣧⢀⠀⠀⠀⠀
⠀⠀⠀⣿⣿⣿⠋⠀⠀⠀⠀⠀⠙⠀⠙⣿⣿⣿⣷⢳⢀⠀⠀⠀
⠀⠀⣠⣿⣿⣿⢸⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⣿⣿⣿⢀
⠀⠀⣸⣿⣿⣿⠸⠀⠀⠀⠒⠒⠒⠐⠀⠀⢿⣿⣿⣿⣿⣿⠀⠀
⠀⣴⣿⣿⣿⡿⠀⠒⣋⣙⡒⢰⠀⠤⣖⠒⢾⣿⣿⣿⣿⣧⠀⠀
⢺⣿⣿⣿⣿⢀⠀⠀⠉⠉⠉⠸⠀⡇⠉⠉⠀⢿⣿⣿⣿⣄⠀⠀
⠀⠙⣿⣿⣧⢻⠀⠀⠀⠀⠀⠠⠀⠰⠀⠀⠀⣸⠸⣿⣿⠿⠰⠀
⠀⠀⠀⠹⣿⣿⣿⣷⠀⡠⠙⣲⣔⣅⢡⣰⣷⣿⣿⣿⣧⠀⠀⠀
⠀⠀⠀⣼⣿⣿⣿⣿⠀⡿⠭⠭⠭⠭⢿⠀⣿⢻⣿⣿⠃⠀⠀⠀
⠀⠀⠀⠙⠛⣿⢻⠹⣿⠐⠙⠛⠟⠉⢀⣴⡟⢿⣿⡏⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⡟⠀⠀⠻⣦⣤⣶⠾⠋⠀⠀⠁⡦⢄⢀⠀⠀⠀
⠀⠀⠀⠀⡠⠁⡇⠑⢄⠀⠀⠀⠀⠀⠀⠔⠀⠀⠁⠀⠀⠀⠉⠁
⠀⠔⠊⠁⠀⠀⣇⠀⠀⠀⠑⡤⠤⢎⠁⠀⠀⡘⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⢢⠠⠀⡠⢆⠀⠀⡠⠙⢄⠀⡸⠀
**/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define mk make_pair
#define pb push_back
#define in insert
#define se second
#define fi first
#define mod 1000000007
#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define all(v) (v).begin(),(v).end()
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(0);
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
#define pii pair<ll,ll>
#define vi(x) vector<x>
#define maxn 100005
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
using namespace std;
using namespace __gnu_pbds;

signed main()
{
    fast;
   
    ll x;
    cin>>x;
    if(x>=30) cout<<"Yes";
    else cout<<"No";
}

Measured memory_bytes: 3604