akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <stack>
using namespace std;

void setUnion(vector<int> &ut, vector<vector<int>> &vec, int n)
{
    vector<bool> checker(n);
    stack<int> seeker;
    for(int i = 0; i < n; ++i)
    {
        if(ut[i] != -1)
        {
            continue;
        }
        seeker.push(i);
        checker[i] = true;
        ut[i] = i;
        while(!seeker.empty())
        {
            int cur = seeker.top();
            seeker.pop();
            for(int j : vec[cur])
            {
                if(checker[j])
                {
                    continue;
                }
                seeker.push(j);
                checker[j] = true;
                ut[j] = ut[cur];
            }
        }
    }
}

int main()
{
    int n,m,k;
    cin >> n >> m >> k;
    vector<vector<int>> friends(n);
    vector<pair<int,int>> dislike(k);
    vector<vector<int>> status(n,vector<int>(2));
    for(int i = 0; i < m; ++i)
    {
        int a,b;
        cin >> a >> b;
        --a;
        --b;
        friends[a].push_back(b);
        friends[b].push_back(a);
        status[a][0] += 1;
        status[b][0] += 1;
    }
    for(int i = 0; i < k; ++i)
    {
        int c,d;
        cin >> c >> d;
        --c;
        --d;
        dislike[i] = make_pair(c,d);
    }
    vector<int> ut(n, -1);
    setUnion(ut,friends,n);
    vector<int> rootCnt(n);
    for(int root : ut)
    {
        rootCnt[root] += 1;
    }

    for(int i = 0; i < k; ++i)
    {
        pair<int,int> p = dislike[i];
        if(ut[p.first] == ut[p.second])
        {
            status[p.first][1] += 1;
            status[p.second][1] += 1;
        }
    }

    for(int i = 0; i < n; ++i)
    {
        if(i != 0)
        {
            cout << " ";
        }
        cout << rootCnt[ut[i]]-status[i][0]-status[i][1]-1;
    }
}

Measured memory_bytes: 13900
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

class main{
    public static void Main(){

        IEnumerable<Char> charas =  (ReadLine());
        var h = new HashSet<char>(charas);
        bool flag = true;

        foreach(char c in h){
            var C = charas.Count(x=> x==c);
            if(C%2==1){
                flag = false;
                break;
            }
        }

        WriteLine(flag? "Yes":"No");
    }
}

Measured memory_bytes: 13396
#from functools import lru_cache
import sys
def vfunc(f): return lambda *lst, **kwargs: list(map(lambda *x:f(*x,**kwargs),*lst))

def reader():return vfunc(lambda l:l.split())(sys.stdin.readlines())

n=reader()[0][0]
i=vfunc(lambda n:int(n))(n)
print('Yes' if sum(i)%9==0 else 'No')

Measured memory_bytes: 85784
import java.io.PrintWriter;
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		PrintWriter pw = new PrintWriter(System.out);
		int H = sc.nextInt();
		int W = sc.nextInt();
		int A = sc.nextInt();
		int B = sc.nextInt();
		
		for(int i=0; i<H; i++) {
			for(int j=0; j<W; j++) {
				pw.print(i<B^j<A ? "0" : "1");
			}
			pw.println();
		}
		
		sc.close();
		pw.close();
	}
}


Measured memory_bytes: 24200
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        long t = Long.parseLong(sc.next());
        long ans = 0;
        long temp = 0;
        for (int i = 0; i < n; i++) {
            long tt = Long.parseLong(sc.next());
            ans += Math.min(tt - temp, t);
            temp = tt;
            if (i == n - 1) {
                ans += t;
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 50064
n=int(input())
XU=[tuple(map(str,input().split())) for i in range(n)]

jpy=0
btc=0

for xu in XU:
    x=xu[0]
    u=xu[1]
    if u=="JPY":
        jpy+=int(x)
    else:
        btc+=float(x)
        
print(jpy+380000*btc)

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

using namespace std;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define fin(ans) cout << (ans) << endl;
#define blank(ans) cout << (ans) << " ";
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()

typedef long long ll;
typedef long long lli;
typedef unsigned long long ull;
typedef long double ld;
typedef string str;

typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<ld> vd;
typedef vector<str> vs;
typedef vector<ll> vll;
typedef vector<pair<ll, ll>> vpll;
typedef vector<pair<ll, str>> vpls;
typedef vector<tuple<str, ll, ll>> vtsl;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
typedef vector<vector<str>> vvs;

const ld PI = acos(-1.0);
const ll MAX = 9000000000000000000;
const ll MIN = -9000000000000000000;
const ld DMAX = 4500;
const ld DMIN = -4500;
const ll MOD = 1000000007;

//実行部
void Main()
{
  str s;
  cin >> s;
  for (ll i = 0; i < 3; i++)
  {
    if (s[i] == '1')
      printf("9");
    else
      printf("1");
  }
  fin("")
}

//前処理
int main()
{
  //ios::sync_with_stdio(false);
  //cin.tie(0);
  cout << fixed << setprecision(20); //高精度少数表示
  Main();
  return 0;
}


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

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef vector<vector<long long>> VVL;
typedef pair<ll,ll> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define EXIST(m,v) (m).find((v)) != (m).end()
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

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

#define en "\n"

constexpr double EPS = 1e-9;
constexpr double PI  = 3.1415926535897932;
constexpr int INF = 2147483647;
constexpr long long LINF = 1LL<<60;
constexpr long long MOD = 1000000007; // 998244353;

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

void Main(){
    ll N,K; cin >> N >> K;
    VL p(N); REP(i,N){cin >> p[i]; p[i]--;}
    VL c(N); REP(i,N) cin >> c[i];

    vector<P> e(N);
    REP(i,N){
        e[i] = P(p[i],c[i]);
    }

    ll ans = -LINF;
    REP(i,N){
        ll now = i, score = 0;
        VI vis(N,-1); vis[now] = 0;
        VL sum_score{0};
        int t = -1, st = -1;
        REP(j,min(K,N)){
            score += e[now].second;
            now = e[now].first;
            sum_score.push_back(score);

            if(vis[now] != -1){
                t = vis[now];
                st = now;
                break;
            }

            vis[now] = j+1;
        }

        if(t == -1){
            ll tmp = -LINF;
            int k = sum_score.size();
            REP(i,k-1) chmax(tmp, sum_score[i+1]);
            chmax(ans, tmp);
            continue;
        }

        ll cycle_score = sum_score.back() - sum_score[t];
        if(cycle_score <= 0){
            ll tmp = -LINF;
            int k = sum_score.size();
            REP(i,k-1) chmax(tmp, sum_score[i+1]);
            chmax(ans, tmp);
            continue;
        }

        ll tmp = -LINF;
        REP(i,t-1) chmax(tmp, sum_score[i+1]);
        chmax(ans, tmp);
        ll res = K - t;

        ll t_cycle = sum_score.size() - t-1;
        ll n_cycle = res/t_cycle; // > 0
        ll mod = res%t_cycle;

        tmp = sum_score[t] + cycle_score*(n_cycle-1);
        now = st;
        REP(i,mod+t_cycle){
            tmp += e[now].second;
            now = e[now].first;
            chmax(ans, tmp);
        }
    }
    cout << ans << en;
    return;
}

int main(void){
    cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);cout<<fixed<<setprecision(15);
    int t=1; //cin>>t;
    REP(_,t) Main();
    return 0;
}

Measured memory_bytes: 3860
from math import sqrt
N, M = map(int, input().split())

import sys
sys.setrecursionlimit(10**6)

MOD = 10**9 + 7
F = [M]
for x in range(2, int(sqrt(M))+1):
    if M % x == 0:
        F.append(x)
        if x != M // x:
            F.append(M // x)
F.sort(reverse=1)
L = len(F)
FF = [1]*(L+1)
fact = [1]*100
rfact = [1]*100
for i in range(L):
    FF[i+1] = FF[i] * (N - i) % MOD
for i in range(99):
    fact[i+1] = r = fact[i] * (i+1)
    rfact[i+1] = pow(r, MOD-2, MOD)
memo = {}
def dfs(i, rest, k):
    key = (i, rest, k)
    if i == L:
        if rest > 1:
            return 0
        return FF[k]
    if key in memo:
        return memo[key]
    f = F[i]
    r = dfs(i+1, rest, k)
    c = 0
    while rest % f == 0:
        rest //= f
        c += 1
        r = (r + dfs(i+1, rest, k+c) * rfact[c]) % MOD
    memo[key] = r
    return r
if M == 1:
    print(1)
else:
    print(dfs(0, M, 0))


Measured memory_bytes: 132472
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;

template<class T> inline T sqr(T x) {return x*x;}

LL gcd(LL m, LL n) {
    if (m < n) swap(m,n);
    while (n > 0) {
        m %= n;
        swap(m,n);
    }
    return m;
}

void solve() {
    int t;
    cin >> t;
    LL a,b,c,d;
    REP(i,0,t) {
        cin >> a >> b >> c >> d;
        LL m = gcd(gcd(a,b), gcd(c,d));
        // LL m = gcd(gcd(a,b), d);
        while (m > 1) {
            a /= m;
            b /= m;
            c /= m;
            d /= m;
            m = gcd(gcd(a,b), gcd(c,d));
            // m = gcd(gcd(a,b), d);
        }
        //cerr << a << " " << b << " " << c << " " << d << endl;
        if (a < b || b > d) {
            cout << "No" << endl;
            continue;
        }
        if (b <= c + 1) {
            cout << "Yes" << endl;
            continue;
        }
        if (d % b == 0) {
            if (a % b <= c) cout << "Yes" << endl;
            else cout << "No" << endl;
            continue;
        }
        LL s = a % b;
        if (s > c || gcd(b,d) == 1) {
            cout << "No" << endl;
            continue;
        }
        LL g = gcd(b,d);
        if ((b - g + s % g) % b <= c) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
}

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

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

long long a[200005];

int main() {
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>a[i];
    long long ans=0;
    long long pos=a[0];
    for(int i=1;i<n;i++){
        if(a[i]<=pos)
            ans+=pos-a[i];
        else{
            pos=a[i];
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 5196
#include<bits/stdc++.h>
#define INF 2000000000
#define MOD 1000000007
#define EPS (1e-10)

using namespace std;

int main(int argc, char *argv[]) {
	
	long a,b,c; cin >> a >> b >> c;
	long k; cin >> k;
	
	long ans = 0;	

	for (int i = 0; i < a; i++) {
		if (k == 0) break;
		ans++;
		k--;
		if (k == 0) break;
	}
	for (int i = 0; i < b; i++) {
		if (k == 0) break;
		k--;
		if (k == 0) break;
	}
	for (int i = 0; i < c; i++) {
		if (k == 0) break;
		ans--;
		k--;
		if (k == 0) break;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  map<char,char> s;
  while(1){
    cin>>n;
    if(n==0) break;
    s.clear();
    for(int i=0;i<n;i++){
      char a,b;
      cin>>a>>b;
      s[a]=b;
    }
    int m;
    cin>>m;
    for(int i=0;i<m;i++){
      char a;
      cin>>a;
      if(s.count(a)==0){
	cout<<a;
      }else{
	cout<<s[a];
      }
    }
    putchar('\n');
  }
}

Measured memory_bytes: 1156
//BISMILLAHIR RAHMANIR RAHIM
//SOTO MEAW
//SOTO SONDESH
#include<bits/stdc++.h>

#define ls ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define __ <<" "<<
#define loop(m,n) for(m=0;m<n;m++)
#define rloop(m,n) for(m=n-1;m>=0;m--)
#define case(z) "Case " << z++ << ": "
#define yes cout << "YES" << endl
#define no cout << "NO" << endl
#define newline cout<<endl
#define quit return 0

using namespace std;

int power(int x, unsigned int y, int p)
{
    int res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
bool miillerTest(int d, int n)
{
    int a = 2 + rand() % (n - 4);
    int x = power(a, d, n);
    if (x == 1  || x == n-1)
       return true;
    while (d != n-1)
    {
        x = (x * x) % n;
        d *= 2;
        if (x == 1)      return false;
        if (x == n-1)    return true;
    }
    return false;
}
bool isprime(int n, int k)
{
    if (n <= 1 || n == 4)  return false;
    if (n <= 3) return true;
    int d = n - 1;
    while (d % 2 == 0)
        d /= 2;
    for (int i = 0; i < k; i++)
         if (!miillerTest(d, n))
              return false;
    return true;
}
int main()
{
    ls
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    //ll int t,l=1;cin>>t;while(t>0){
        ll int a,b,c,d,sum=1;
        cin >> a >> b >> c >> d ;
        sum=b*d;
        if(sum<a*d) sum=a*d;
        if(sum<a*c) sum=a*c;
        if(sum<b*c) sum=b*c;
        cout << sum ;
    //t--;}
    quit;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI (3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

/*他のライブラリを入れる場所*/


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll a,b;
	cin>>a>>b;

	rep(i,100000){
		if(i*8/100 == a and i/10 == b){
			puta(i);
			return 0;
		}
	}
	puta(-1);
	return 0;
}

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

int par[100100];
int rankdesu[100100];
long num[100100];
int n,m;

void init(int n){
  for(int i = 0;i < n;i++){
    par[i] = i;
    rankdesu[i] = 0;
    num[i] = 1;
  }
}

int find(int x){
  if(par[x] == x){
    return x;
  }
  else{
    return par[x] = find(par[x]);
  }
}

void unite(int x,int y){
  x = find(x);
  y = find(y);
  if(x == y) return;
  if(rankdesu[x] < rankdesu[y]){
    par[x] = y;
    num[y] += num[x];
  }
  else{
    par[y] = x;
    num[x] += num[y];
    if(rankdesu[x] == rankdesu[y])rankdesu[x]++;
  }
}
bool same(int x,int y){
  return find(x) == find(y);
}

int main(){
  cin >> n >> m;
  int a[m],b[m];
  long ln = n;
  for(int i = 0;i < m;i++){
    cin >> a[i] >> b[i];
    a[i]--;b[i]--;
  }
  init(n);
  long ans[m];
  ans[m-1] = ln*(ln-1)/2;
  for(int i = m - 2;i >= 0;i--){
    if(!same(a[i+1],b[i+1])){
      //cout << a[i] << ' ' << b[i] << ' ' << num[find(a[i])] << ' ' << num[find(b[i])] << endl;
      ans[i] = ans[i+1] - (num[find(a[i+1])]*num[find(b[i+1])]);
    }
    else{
      ans[i] = ans[i+1];
    }
    unite(a[i+1],b[i+1]);
  }
  for(int i = 0;i < m;i++){
    cout << ans[i] << endl;
  }
}

Measured memory_bytes: 4480
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif
// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;

#define rep(i,n) for(int i=0; i<((int)n); i++)
#define REP(i,n) for(int i=0; i<=((int)n); i++)
#define srep(i,a,n) for(int i=a; i<((int)n); i++)
#define SREP(i,a,n) for(int i=a; i<=((int)n); i++)
#define rrep(i,n) for(int i=n-1; i>=0; i--)
#define RREP(i,n) for(int i=n; i>=0; i--)
#define INF 1000000000
const int mod = INF+7;

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

  long ans=(long)N*(N-1)/2;
  printf("%ld\n", ans);
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;


int main(){
    long long int n,max,sum;
    cin>>n;
    vector<long long int>p(70000);
    vector<long long int>q(70000);
    while(n!=0){

        max=0;
        sum=0;
        for(long long int i=0;i<n;i++){
            cin>>p[i];
            sum+=p[i];
        }
        for(long long int i=0;i<n-1;i++){
            cin>>q[i];
        }
        sort(p.begin(),p.end(),greater<>());
        sort(q.begin(),q.end(),greater<>());
        max=sum*n;
        for(long long int i=0;i<n-1;i++){
            sum+=q[i];
            if(max<sum*(n-i-1)){
                max=sum*(n-i-1);
            }
        }
        cout<<max<<endl;

        cin>>n;
    }
    return 0;
}



Measured memory_bytes: 3816
n = gets.to_i
array = gets.split(" ").map(&:to_i)

(1..n).each do |i|
  if array[i-1] % 2 == 0
    if array[i-1] % 3 == 0 || array[i-1] % 5 == 0
    else
      puts "DENIED"
      exit
    end
  end
end

puts "APPROVED"


Measured memory_bytes: 14408
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];

  ll ans = 0;
  int d=0,l=0,r=0;
  while(l<n){
    while( r<n && (d^a[r])==(d+a[r]) ) d ^= a[r++];
    ans += ll(r-l);
    d ^= a[l++];
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define io_optimized ios::sync_with_stdio(false);cin.tie(0);
using namespace std;
 
int main () {
	io_optimized
	int a,b;
	while(cin>>a>>b)
	{
		if(a==b)
		{
			cout<<"Yes\n";
		}
		else
		{
			cout<<"No\n";
		}
	}
 
	return 0;
}

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

using namespace std;

int main(){
	int n;
	cin >> n;
	int arr[n+1];
	for(int i=1;i<=n;i++){
		int a; cin >> a;
		arr[a]=i;
	}
	for(int i=1;i<=n;i++)
		cout << arr[i] << " ";
	cout << endl;
	return 0;
	
}

Measured memory_bytes: 1152
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

vector< u64 > A = vector< u64 >(50, 0);
vector< u64 > B = vector< u64 >(50, 0);

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

    int N, M;
    cin >> N >> M;

    string s;
    rep (i, N)
    {
        cin >> s;
        rep (j, N)
        {
            A[i] = (A[i] << 1) + (s[j] == '.' ? 0 : 1);
        }
    }
    rep (i, M)
    {
        cin >> s;
        rep (j, M)
        {
            B[i] = (B[i] << 1) + (s[j] == '.' ? 0 : 1);
        }
    }
    u64 mask = 0;
    rep (i, M) mask = (mask << 1) + 1;

    bool ans = false;
    for (int i = 0; i < N - M + 1 && !ans; ++i)
    {
        for (int j = 0; j < N - M + 1 && !ans; ++j)
        {
            int temp = 0;
            rep (ii, M)
            {
                temp |= ((A[i + ii] >> (N - M - j)) & mask) ^ B[ii];
            }
            if (temp == 0) ans = true;
        }
    }

    if (ans) cout << "Yes\n";
    else cout << "No\n";

    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
int32_t main()
{
  int t,n,i,j,k,l=0,min1=0;
  cin>>n;
  int a[n+1];
  for(i=1;i<=n;i++)
   cin>>a[i];
   sort(a+1,a+n+1);
  for(i=1;i<=(n-2);i++)
  {
    for(j=i+1;j<n;j++)
    {
      for(k=j+1;k<=n;k++)
      {
        if(a[i]!=a[j]&&a[j]!=a[k]&&a[k]!=a[i])
        {
          if(a[i]+a[j]>a[k])
           l++;
        }
      }
    }
  }
  cout<<l;
}

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

int main(){
	int N, K;
	cin >> N >> K;
	int h[N];
	for(int i=0; i<N; i++){
		cin >> h[i];
	}
	sort(h, h+N);
	int min = h[K-1] - h[0];
	for(int i=0; i<N-K+1; i++){
		if(min > h[i+K-1] - h[i]){
			min = h[i+K-1] - h[i];
		}
	}
	cout << min << endl;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<double> vd;
typedef pair<double,double> PD;
typedef pair<int,P> ed;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
const double eps = 1e-10;
  
int main() {
  int N,M;
  cin >> N >> M;
  cout << (N-1)*(M-1) << endl;
  return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
#行列
s = []
for i in range(m):#h:高さ
    s.append([int(w) for w in input().split()])
s.sort(key=lambda x:(x[0], x[1]))
adj = []
for i in range(n):
    adj.append([])
for i in range(n):
    for j in range(n):
        adj[i].append(0)
#鱗屑行列
for i in range(m):
    adj[s[i][0] - 1][s[i][1] - 1] = 1
    adj[s[i][1] - 1][s[i][0] - 1] = 1

#深さ優先探索
labelli = [-1]*n
label = 0
v = 0
labelli[0] = label
p = 0
back = []
backnumber = []
q = 0
count = 0
for h in range(m):
    if h == 0:
        adj[s[h][0] - 1][s[h][1] - 1] = 0
        adj[s[h][1] - 1][s[h][0] - 1] = 0
    else:
        adj[s[h - 1][0] - 1][s[h - 1][1] - 1] = 1
        adj[s[h - 1][1] - 1][s[h - 1][0] - 1] = 1
        adj[s[h][0] - 1][s[h][1] - 1] = 0
        adj[s[h][1] - 1][s[h][0] - 1] = 0
        q = 0
        labelli = [-1] * n
        label = 0
        labelli[0] = label
    while q == 0:
        for j in range(n):
            if adj[v][j] == 1 and labelli[j] == -1:#未探索部分を掘る
                label += 1
                v = j
                labelli[j] = label
                p = 1
                break
        if v == 0:
            for l in range(n):
                if adj[v][j] == 1 and labelli[j] == -1:#初期地点で、未探索部分があるかチェック、なければ終了
                    break
                if l == n - 1:
                    q = 1
                    p = 1
                    if min(labelli) == -1:
                        count += 1
        if p == 0:#未探索がなければ戻る
            for k in range(n):
                if adj[v][k] == 1:
                    if labelli[v] > labelli[k]:
                        back.append(abs(labelli[v] - labelli[k]))
                        backnumber.append(k)
            v = backnumber[back.index(min(back))]
            back = []
            backnumber = []
        p = 0

print(count)

Measured memory_bytes: 3192
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define vi vector<int>
#define vvi vector<vector<int>>
#define all(a) (a).begin(), (a).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
const int MOD = 1e9+7;
const ll LINF = 1e18;
const int INF = 1e9;
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;

int main()
{
    vector<ll> waru(20);
    cin >> N;
    
    A = 26;
    waru[1]  = 1;
    for (ll i = 1; i <= 12; i++,A=26+A*26)
    {
        waru[i+1] = waru[i] *26;
        if(N-A<=0)
        {
            B=i;
            N-=C;
            break;
        }
        C = A;
    }

    for (int i = B; i > 0; i--)
    {
        while(N-waru[i] >0)
        {
            N-=waru[i];
            D++;
        }
        cout<<(char)('a'+D);
        D = 0;
    }
    





    
    return 0;
}

Measured memory_bytes: 3608
import java.util.Scanner;

/**
 * Created by dizzyvn on 6/24/17.
 */
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();

        int z = b - a;

        if (z <= 0) {
            System.out.println("delicious");
        }
        else if (z <= x) {
            System.out.println("safe");
        } else {
            System.out.println("dangerous");
        }
    }
}

Measured memory_bytes: 21972
# -*- coding: utf-8 -*-

surplus = [0]*2019
surplus[0] += 1

d = 1
n = 0
for i in reversed(input()):
    n = (n + int(i)*d) %2019
    d = d*10 % 2019
    surplus[n] += 1

print(sum([i*(i-1)//2 for i in surplus]))


Measured memory_bytes: 9240
o, e = input(), input()

ans =  ""
if len(o) == len(e):
    for c1, c2 in zip(o, e):
        ans += c1 + c2
else:
    for c1, c2 in zip(o[:-1], e):
        ans += c1 + c2
    ans += o[-1]

print(ans)


Measured memory_bytes: 8900
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>

int main()
{
    int K,X;
    std::cin >> K >> X;
    for(int i=0; i<2*K-1;i++){
        std::cout << X-(K-1)+i << " ";
    }
    std::cout << std::endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <unordered_map>
#include <cstring>
#include <chrono>
#include <vector>
#include <map>
#include <random>
#include <set>
#include <algorithm>
#include <math.h>
#include <cstdio>
#include <stdio.h>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <deque>
#include <cassert>
#include <stack>
using namespace std;

#define max3(a, b, c) max(a, max(b, c))
#define min3(a, b, c) min(a, min(b, c))
#define mp make_pair
#define f first
#define se second
#define pb push_back
#define ppb pop_back
#define ll long long
#define y1 abcde
#define ull unsigned long long
#define cntbit(x) __builtin_popcount(x)
#define endl '\n'
#define uset unordered_set
#define umap unordered_map
#define all(x) x.begin(), x.end()
#define pii pair<int, int>
#define ld long double
#define pll pair<long long, long long>
#define int long long

const ll inf = 2e18;
const int L = 61;
const int N = 2e5 + 15;
int n, k, a[N], g[L][N], last[N], first[N];
bool used[N];
vector <int> ans;

main() {
    ios_base::sync_with_stdio(0); cout.tie(0); cin.tie(0);
    fill(last, last + N, -1);
    fill(first, first + N, -1);
    cin >> n >> k;
    for(int i = 0; i < n; ++i) {
        cin >> a[i];
        if(first[a[i]] == -1)
            first[a[i]] = i;
    }
    for(int i = n - 1; i >= 0; --i)
        last[a[i]] = i + n;
    for(int i = n - 1; i >= 0; --i) {
        g[0][i] = last[a[i]] - i + 1;
        last[a[i]] = i;
    }
    for(int i = 1; i < L; ++i)
        for(int j = 0; j < n; ++j)
            g[i][j] = min(inf, g[i-1][j] + g[i-1][(j + g[i-1][j]) % n]);
    int j = 0;
    for(int i = L - 1; i >= 0; --i)
        if(g[i][j % n] + j < n * k)
            j += g[i][j % n];
    for(int i = j % n; i < n; ++i) {
        if(!used[a[i]]) {
            ans.pb(a[i]);
            used[a[i]] = true;
        }
        else
            while(used[a[i]]) {
                used[ans.back()] = false;
                ans.ppb();
            }
    }
    for(int i : ans)
        cout << i << ' ';
    return 0;
}

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

using namespace std;

int main(void) {
    int N, M;
    cin >> N >> M;
    vector<int> ans(M);
    for(int i=0; i<N; i++) {
        int K;
        cin >> K;
        for(int j=0; j<K; j++) {
            int A;
            cin >> A;
            ans.at(--A)++;
        }
    }
    cout << count(ans.begin(), ans.end(), N) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <queue>
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){

	int w,h;
	int xs,ys;
	int xg,yg;
	int n;
	while(cin>>w>>h&&!(w==0&&h==0)){
		int field[101][101];
		for(int i = 0; i < 101; i++)
			fill(field[i],field[i]+101,0);

		cin>>xs>>ys;
		cin>>xg>>yg;
		xs--;ys--;xg--;yg--;
		cin>>n;
		for(int i = 0; i < n; i++){
			int c,d,x,y;
			cin>>c>>d>>x>>y;
			x--;y--;
			if(d==0){
				for(int j = y; j < 2+y; j++){
					for(int k = x; k < x + 4; k++){
						field[j][k]=c;
					}
				}
			}
			else{
				for(int j = y; j < 4+y; j++){
					for(int k = x; k < x + 2; k++){
						field[j][k]=c;
					}
				}
			}
		}
		// bfs
		int c=field[ys][xs];

		if(c==0){
			cout<<"NG"<<endl;
			continue;
		}
		queue<pair<int,int> > *prv=new queue<pair<int,int> >();
		queue<pair<int,int> > *nxt=new queue<pair<int,int> >();

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

		bool passed[101][101];
		for(int i = 0; i < 101; i++)
			fill(passed[i],passed[i]+101,false);

		prv->push(make_pair(ys,xs));

		bool fin=false;
		while(prv->size()){
			while(prv->size()){
				pair<int,int> p = prv->front();
				prv->pop();
				if(p.first==yg&&p.second==xg){
					fin=true;
					break;
				}

				if(passed[p.first][p.second])
					continue;
				passed[p.first][p.second]=true;
				for(int i = 0; i < 4; i++){
					int ny=p.first+dy[i];
					int nx=p.second+dx[i];
					if(ny>=0&&nx>=0&&ny<h&&nx<w&&field[ny][nx]==c&&!passed[ny][nx]){
						nxt->push(make_pair(ny,nx));
					}
				}
			}
			if(fin)
				break;
			swap(prv,nxt);
		}
		if(fin){
			cout<<"OK"<<endl;
		}
		else
			cout<<"NG"<<endl;
		delete prv,nxt;
	}

	return 0;
}

Measured memory_bytes: 0
// Template
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <numeric>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>

using namespace std;
typedef long long ll;

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

int MOD = 1000000007;

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

    int n; cin >> n;
    std::vector<ll> v(n); REP(i,n) cin >> v[i];
    sort(v.begin(),v.end());

    ll c = v[0]; int k=0;
    for(int i=1; i<n; ++i){
        if(2*c < v[i]){
            k=i;
        }
        c+=v[i];
    }

    cout << n-k << endl;
    return 0;
}


Measured memory_bytes: 1024
# ?????§?????????????????????
import sys

pattern = ['#', '.']

while True:
    data = sys.stdin.readline().strip().split(' ')
    h = int(data[0])
    w = int(data[1])

    if h == 0 and w == 0:
        break

    pat_idx = 0
    st_pat_idx = 0
    for i in range(h):
        for j in range(w):
            print(pattern[pat_idx], end='')
            pat_idx = 1 - pat_idx # pat_idx <- 0, 1, 0, 1...?????°?????????

        st_pat_idx = 1 - st_pat_idx
        pat_idx = st_pat_idx
        print('')

    print('')

Measured memory_bytes: 8964
#include <iostream>

using namespace std;
typedef long long ll;
ll mod = 1000000007;
ll pw(ll a,ll x){
    ll ret = 1;
    while(x){
        if(x&1) (ret *= a) %= mod;
        (a *= a) %= mod; x /= 2;
    }
    return ret;
}

int main(){
    int i,n; cin >> n;
    ll ans = pw(10,n) - 2*pw(9,n) + pw(8,n);
    while(ans<0) ans += mod;
    ans %= mod;
    cout << ans << endl;
}


Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

void split( std::vector<std::string> &list, std::string string, std::string separator )
{
  auto separator_length = separator.length();
  if ( separator_length == 0 )
  {
    list.push_back( string );
  } else {
    auto offset = std::string::size_type( 0 );
    while( 1 )
    {
      auto pos = string.find( separator, offset );
      if( pos == std::string::npos )
      {
        list.push_back( string.substr( offset ) );
        break;
      }
      list.push_back( string.substr( offset, pos - offset ) );
      offset = pos + separator_length;
    }
  }
}

template<typename T>
T min( T a, T b )
{
  return ( a < b ) ? a : b;
}

template<typename T>
T max( T a, T b )
{
  return ( a > b ) ? a : b;
}

int main(void)
{
  std::string S;
  std::cin >> S;
  //S = "RRLRL";

  int N = S.size();
  std::vector<int> num(N);

  for( int i = 0;i < 2;i++ ){
    int cnt = 0;

    for( int j = 0;j < N;j++ ){
      if( S[j] == 'R' ) cnt++;
      else {
        num[j] += cnt/2;
        num[j-1] += (cnt+1)/2;
        cnt = 0;
      }
    }

    std::reverse( num.begin(), num.end() );
    std::reverse( S.begin(), S.end() );
    for( int j = 0;j < N;j++){
      if( S[j] == 'L' ) S[j] = 'R';
      else S[j] = 'L';
    }
  }
  

  for( int i = 0;i < N;i++ ){
    std::cout << num[i] << " ";
  }
  std::cout << std::endl;

  

  return 0;
}


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

using namespace std;

#define int long long
#define fi first
#define se second

const int mod0 = 1e9 + 9, mod1 = 1e9 + 7, base = 500005;
int n, pwbase[2][base], hashs[2][base], cur = 250000, ans, start[base];
string s;
map< pair<int, int>, int> cnt;

int binpw (int aa, int mm, int mod) {
    int ret = 1;
    for (; mm; mm >>= 1, aa = (aa * aa) % mod) if (mm & 1) ret = (ret * aa) % mod;
    return ret;
}

signed main () {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n >> s; s = '*' + s;
    pwbase[0][0] = pwbase[1][0] = 1;
    for (int i = 1; i < base; ++i) {
        pwbase[0][i] = (pwbase[0][i - 1] * base) % mod0;
        pwbase[1][i] = (pwbase[1][i - 1] * base) % mod1;
    }
    for (int i = 1; i <= n; ++i) {
        start[i] = cur;
        if(s[i] == '<') cur --;
        else if(s[i] == '>') cur ++;
        hashs[0][i] = hashs[0][i - 1];
        hashs[1][i] = hashs[1][i - 1];
        if (s[i] == '+') {
            hashs[0][i] = (hashs[0][i] + pwbase[0][cur]) % mod0;
            hashs[1][i] = (hashs[1][i] + pwbase[1][cur]) % mod1;
        }
        else if (s[i] == '-') {
            hashs[0][i] = ( (hashs[0][i] - pwbase[0][cur]) % mod0 + mod0) % mod0;
            hashs[1][i] = ( (hashs[1][i] - pwbase[1][cur]) % mod1 + mod1) % mod1;
        }
    }

    pair<int, int> X = { (hashs[0][n] * binpw(pwbase[0][ start[1] ], mod0 - 2, mod0) ) % mod0,
                        (hashs[1][n] * binpw(pwbase[1][ start[1] ], mod1 - 2, mod1)) % mod1 };

    for (int i = n; i > 0; --i) {
        cnt[ { hashs[0][i], hashs[1][i] } ] ++;
        ans += cnt[ { (X.fi * pwbase[0][ start[i] ] + hashs[0][i - 1]) % mod0, (X.se * pwbase[1][ start[i] ] + hashs[1][i - 1]) % mod1 } ];
    }

    cout << ans;

    return 0;
}


Measured memory_bytes: 51228
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define INF (1ll<<60)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
const lint MOD =1000000007;
const lint MAX = 10000000;

 
lint fac[MAX], finv[MAX], inv[MAX];

void COMinit() // 二項係数を求める時は前処理としてCOMinit()をする
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (lint i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
// 二項係数計算
long long COM(lint n, lint k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

lint primary(lint num)
{
    if (num < 2) return 0;
    else if (num == 2) return 1;
    else if (num % 2 == 0) return 0; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return 0;
        }
    }

    // 素数である
    return 1;
}


  int main(){
     lint accum1=0,accum2=0;
    lint N;
    cin >>N; lint A[N]; lint B[N];
    rep(i,N){cin >> A[i];
        accum1+=A[i];
    }
    lint D[N];
    rep(i,N){cin >> B[i];
        accum2+=B[i];
        D[i]=A[i]-B[i];
    }
    lint ans=0;
     lint accum3=0;
    sort(D,D+N);
    lint v=0;
    while(1){
            if(D[v]<0){
                ans++;
                accum3+=D[v];
            }else break;
            v++;
    }
    if(accum2>accum1){
        cout<<-1;
    }else{
            lint g=N-1;
            while(1){
                if(accum3>=0){
                    cout<<ans;
                    return 0;
                }
                accum3+=D[g];
                 ans++;
                g--;
            }
    }
   
  }

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

const int max_city = 50;
int square[max_city][max_city];

int main () {

    int N, M;
    cin >> N >> M;

    for (int i = 0; i < M; i++) {
        int a, b;
        cin >> a >> b;
        a--; b--;

        square[a][b]++;
        square[b][a]++;
    }

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

        int cnt = 0;

        for (int j = 0; j < N; j++) {
            cnt += square[i][j];
        }

        cout << cnt << endl;
    }

    return 0;
}

Measured memory_bytes: 256
def SumOfDiv(n):
	i = 2
	ans = 1
	while i*i <= n:
		c = 0
		while n%i==0:
			n /= i
			c += 1
		if c > 0:
			ans *= (i**(c+1)-1)/(i-1)
		i += 1
	if n > 1:
		ans *= (1+n)
	return ans
	
while 1:
	n = input()
	if n == 0: break
	d = SumOfDiv(n) - n
	if d == n:
		print "perfect number"
	elif d < n:
		print "deficient number"
	else:
		print "abundant number"

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

#define NREP() for(ll i = 0; i < n; i++)
#define MREP() for(ll j = 0; j < m; j++)
#define REP(i, x, y) for(ll i = x; i < y; i++)
#define ALL(x) (x).begin(), (x).end()
#define MSG(x) cout << x << endl;
#define MSGF(x, n) MSG(fixed << setprecision(n) << x)
#define END(x) cout << x << endl; exit(0);
#define IPT(v, n) REP(i, 0, n){ cin >> v[i]; }
#define YN(x) x ? cout << "YES" << endl : cout << "NO" << endl;
#define Yn(x) x ? cout << "Yes" << endl : cout << "No" << endl;
#define yn(x) x ? cout << "yes" << endl : cout << "no" << endl;

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<ull> vul;
typedef vector<vector<ull>> vvul;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;

const static ll MOD = 1e9 + 7;
const static ll INF = 1LL << 30;

ll a, b, c, d, k, l, m, n, h, w, q, x, y;
string s, t;

ll ans = 0;
ll sum = 0;
ll cnt = 0;
ll cur = 0;
ll tmp = 0;
ll mini = INF;
ll maxi = 0;

double ave = 0.0;

ll mod_pow(ll base, ll power) {
    if (power == 0) return 1;
    if (power == 1) return base % MOD;
    if (power % 2 == 0) return ((mod_pow(base % MOD, (power / 2)) % MOD) * (mod_pow(base, (power / 2)) % MOD)) % MOD;
    return (base % MOD * (mod_pow(base % MOD, power - 1) % MOD)) % MOD;
}

ll mod_fact(ll number) {
    ll ret = 1;
    ll count = 1;
    while (count <= number) {
        ret *= (count % MOD);
        ret %= MOD;
        count++;
    }
    return ret % MOD;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

ll calc(vl one, vl two, ll idx) {
    ll ret = 0;
    REP(i, 0, idx + 1) {
        ret += one[i];
    }
    REP(i, idx, n) {
        ret += two[i];
    }
    return ret;
}

int main() {
    cin >> n;
    vl one(n + 10), two(n + 10);
    IPT(one, n)
    IPT(two, n)
    NREP() {
        ans = max(ans, calc(one, two, i));
    }
    MSG(ans)
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>

using namespace std;

#define REP(a, i, n) for (int i = a; i < n; ++i)
#define RREP(a, i, n) for (int i = n - 1; i >= a; --i)

void swap(int &A, int &B) {
    int T = A;
    A = B;
    B = T;
}

struct UnionFind {
    vector<int> parentOf;
    vector<long> sz;

    UnionFind(int N) {
        parentOf.resize(N);
        sz.resize(N, 1);
        REP(0, i, N) {
            parentOf[i] = i;
        }
    }

    int rootOf(int x) {
        int p = parentOf[x];
        if (p == x) {
            return p;
        } else {
            int r = rootOf(p);
            parentOf[x] = r;
            return r;
        }
    }

    bool isSame(int x, int y) {
        return rootOf(x) == rootOf(y);
    }

    bool merge(int x, int y) {
        int rx = rootOf(x);
        int ry = rootOf(y);
        if (rx == ry) {
            return false;
        } else {
            if (sz[rx] < sz[ry]) {
                swap(rx, ry);
            }

            sz[rx] += sz[ry];

            parentOf[ry] = rx;

            return true;
        }
    }

    long size(int x) {
        return sz[rootOf(x)];
    }
};

int main() {
    long N, M;
    cin >> N >> M;

    int A[M], B[M];
    REP(0, i, M) {
        cin >> A[i] >> B[i];
        --A[i]; --B[i];
    }

    UnionFind uf = UnionFind(N);
    long ans = N * (N - 1) / 2;
    vector<long> v;
    v.push_back(ans);
    RREP(0, i, M) {
        if (uf.isSame(A[i], B[i])) {
            v.push_back(ans);
        } else {
            ans -= uf.size(A[i]) * uf.size(B[i]);
            v.push_back(ans);
            uf.merge(A[i], B[i]);
        }
    }

    RREP(0, i, M) {
        printf("%ld\n", v[i]);
    }

    return 0;
}


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

using namespace std;

#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(a)  (a).begin(),(a).end()
using ll = long long;
using Pair = pair<int, int>;
const ll mod = 1e9 + 7;


string f(string str) {
  string s(1, str[0]);
  string e(1, str[str.size() - 1]);
  return s + e;
}

string g(int a, int b) {
  return to_string(a) + to_string(b);
}

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

  map<string, ll> m = {
    {"11", 0},{"12", 0},{"13", 0},{"14", 0},{"15", 0},{"15", 0},{"16", 0},{"18", 0},{"19", 0},
    {"21", 0},{"22", 0},{"23", 0},{"24", 0},{"25", 0},{"25", 0},{"26", 0},{"28", 0},{"29", 0},
    {"11", 0},{"32", 0},{"33", 0},{"34", 0},{"35", 0},{"35", 0},{"36", 0},{"38", 0},{"39", 0},
    {"41", 0},{"42", 0},{"43", 0},{"44", 0},{"45", 0},{"45", 0},{"46", 0},{"48", 0},{"49", 0},
    {"51", 0},{"52", 0},{"53", 0},{"54", 0},{"55", 0},{"55", 0},{"56", 0},{"58", 0},{"59", 0},
    {"61", 0},{"62", 0},{"63", 0},{"64", 0},{"65", 0},{"65", 0},{"66", 0},{"68", 0},{"69", 0},
    {"71", 0},{"72", 0},{"73", 0},{"74", 0},{"75", 0},{"75", 0},{"76", 0},{"78", 0},{"79", 0},
    {"81", 0},{"82", 0},{"83", 0},{"84", 0},{"85", 0},{"85", 0},{"86", 0},{"88", 0},{"89", 0},
    {"91", 0},{"92", 0},{"93", 0},{"94", 0},{"95", 0},{"95", 0},{"96", 0},{"98", 0},{"99", 0}};

  for (int i = 1; i <= n; i++) {
    string s = f(to_string(i));
    if (s[1] == '0') continue;
    m[s]++;
  }

  ll ans = 0;
  for (int i = 1; i <= 9; i++) {
    for (int j = 1; j <= 9; j++) {
      string s = g(i, j);
      string t = g(j, i);
      ans += m[s] * m[t];
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
while 1:
    try:
        t = map(int, raw_input().split())
        s = 0
        ans = []
        for i in range(3):
            s += (t[i+3] - t[i]) * (60**(2-i))
        for i in range(3):
            d, s = divmod(s,(60**(2-i)))
            ans += [d]
        print  " ".join(map(str,ans))
    except EOFError: break

Measured memory_bytes: 6252