akhauriyash/Code-Regression huggingface dataset:
def slove():
    import sys
    input = sys.stdin.readline
    n = int(input().rstrip('\n'))
    ls = [0] * n
    a = list(map(int, input().rstrip('\n').split()))
    for i, v in enumerate(a):
        t = v
        while True:
            if t % 2 == 0:
                ls[i] += 1
                t //= 2
                if ls[i] == 2:
                    break
            else:
                break
    if len(ls) % 2 == 0:
        print("Yes" if ls.count(2) >= ls.count(0) else "No")
    else:
        print("Yes" if ls.count(2) >= ls.count(0) - 1 else "No")


if __name__ == '__main__':
    slove()


Measured memory_bytes: 15020
N, M = list(map(int, input().split()))
H = list(map(int, input().split()))
t = {}
for n in range(1, N+1):
    t[n] = H[n-1]

r = set()
for m in range(M):
    A, B = list(map(int, input().split()))
    if t[A] < t[B]:
        r.add(A)
    elif t[B] < t[A]:
        r.add(B)
    else:
        r.add(A)
        r.add(B)
print(len(set(t.keys()) - r))        

Measured memory_bytes: 33364
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define SZ(x) ((int)(x).size())
#define rep(i,n) for(int i=0;i<(n);++i)
#define fore(i,a) for(auto &i:a)
#define min(...) min({__VA_ARGS__})
#define max(...) max({__VA_ARGS__})
#define Yes cout << "Yes" << endl;
#define No cout << "No" << endl;
#define ALL(x) (x).begin(),(x).end()
signed _main(); signed main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> using v = vector<T>;
template<class T> using vv = vector<v<T>>;
const int MOD=1e9+7;
const long long INF = 1LL << 60;
using P=pair<int,int>;

signed _main(){
  // 頂点数と辺数
  int H,W; cin >> H >> W;
  int dx[4]={1,0,-1,0};
  int dy[4]={0,1,0,-1};
  vv<char> field(H,v<char>(W));
  int cnt=0;
  rep(i,H)rep(j,W){
    cin >> field[i][j];
    if(field[i][j]=='#') cnt++;
  }

  // BFS のためのデータ構造
  vv<int> dist(H, v<int>(W,-1)); // 全頂点を「未訪問」に初期化
  queue<P> que;

  // 初期条件 (頂点 0 を初期ノードとする)
  dist[0][0] = 1;
  que.push(P(0,0)); // 0 を橙色頂点にする

  // BFS 開始 (キューが空になるまで探索を行う)
  while (!que.empty()) {
    P v = que.front(); // キューから先頭頂点を取り出す
    que.pop();

    // v から辿れる頂点をすべて調べる
    rep(i,4){
      int x=v.first+dx[i];
      int y=v.second+dy[i];
      if(x<0 || x>=H || y<0 || y>=W) continue;
      if(field[x][y]=='#') continue;
      if(dist[x][y]!=-1) continue;
      dist[x][y]=dist[v.first][v.second]+1;
      que.push(P(x,y));
    }
  }
  if(dist[H-1][W-1]==-1) cout << -1 << endl;
  else cout << H*W-cnt-dist[H-1][W-1] << endl;
}


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

#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
typedef long double ld;

const ll mod = (ll)1e9 + 7;
const ll mxN = 200200;



void solve(){
	ll n,d;
	cin>>d>>n;
	if(d==0) {if(n==100)cout<<101<<"\n";else cout<<n;}
	else if(d==1) {if(n==100)cout<<100*101<<"\n";else cout<<100*n;}
	else {if(n==100)cout<<10000*101<<"\n";else cout<<10000*n;}

}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.precision(20);
	cout << fixed;

	//ll t;cin>>t;while(t--)
	solve();

}


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

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

int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
	
	int n,m,x,y;
	cin>>n>>m>>x>>y;
	vi a(n+1),b(m+1);
	rep(i,n)cin>>a[i];
	a[n]=x;
	rep(i,m)cin>>b[i];
	b[m]=y;
	if(*max_element(all(a))<*min_element(all(b))){
	    cout<<"No War"<<endl;
	}else cout<<"War"<<endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		new Main().run();
	}

	private void run() {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		while (n-- > 0) {
			long s = Long.parseLong(scanner.next(), 16);
			int x = (int) (s & (1 << 31) - 1) >> 7;
			double y = (double) ((s & 0x7f) * 0.0078125);
			String a = String.valueOf(y).substring(2);
			if (s >> 31 > 0)
				System.out.print("-");
			System.out.printf("%d.%s\n", x, a);
		}
	}
}

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

int main(){
  int h,w,n;
  cin >> h >> w >> n;

  int px,py,x,y;
  cin >> px >> py;
  
  int res = 0;
  for(int i=0;i<n-1;i++){
    cin >> x >> y;
    int dx = x-px, dy = y-py;
    if(dx*dy<0){
      res += abs(dx) + abs(dy);
    }else{
      res += max(abs(dx),abs(dy));
    }
    px = x; py = y;
  }

  cout << res << endl;
}

Measured memory_bytes: 1160
import sys

class Node:
    __slots__ = ['key', 'left', 'right']
    def __init__(self, key):
        self.key = key
        self.left = self.right = None

root = None

def insert(key):
    global root
    x, y = root, None
    while x: x, y = x.left if key < x.key else x.right, x
    if y is None: root = Node(key)
    elif key < y.key: y.left = Node(key)
    else: y.right = Node(key)

def find(target):
    result = root
    while result and target != result.key:
        result = result.left if target < result.key else result.right
    return result is None

def inorder(node):
    return inorder(node.left) + f' {node.key}' + inorder(node.right) if node else ''
def preorder(node):
    return f' {node.key}' + preorder(node.left) + preorder(node.right) if node else ''

input()
for e in sys.stdin:
    if e[0] == 'i': insert(int(e[7:]))
    elif e[0] == 'f': print(['yes','no'][find(int(e[5:]))])
    else: print(inorder(root)); print(preorder(root))


Measured memory_bytes: 55628
import numpy as np
n=int(input())
s=input()

r=[]
g=[]
b=[]

for i in range(0,n):
    if s[i]=='R':
        r.append(i)

    elif s[i]=='G':
        g.append(i)

    elif s[i]=='B':
        b.append(i)

s3=0
rl=len(r)
gl=len(g)
bl=len(b)

for i in range(0,n-2):
    n2=int((n+i)/2)+1
    for j in range(i,n2):
        k=2*j-i
        if k<=n-1:
            
            if s[i]!=s[j] and s[i]!=s[k] and s[j]!=s[k]:
                s3+=1
s2=rl*gl*bl-s3
print(s2)

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

using namespace std;

int N;

int main(){
    cin>>N;
    int h[N+1];
    int dp[N+1];
    for(int i=1; i <= N; i++){
        cin>>h[i];
    }

    dp[1] = 0;
    dp[2] = dp[1] + abs(h[2] - h[1]);
    for(int i=3; i <= N; i++){
        dp[i] = min((dp[i-1] + abs(h[i] - h[i-1])), (dp[i-2] + abs(h[i] - h[i-2])));
    }
    cout<<dp[N];

    return 0;
}


Measured memory_bytes: 4372
S = input()

no = False
so = False
ea = False
we = False
for s in S:
    if s == 'N':
        no = True
    elif s == 'S':
        so = True
    elif s == 'E':
        ea = True
    elif s == 'W':
        we = True

if ((no and so) or (not no and not so)) and ((ea and we) or (not ea and not we)):
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
/*
* @Author: 王文宇
* @Date:   2018-03-17 23:59:48
* @Last Modified by:   王文宇
* @Last Modified time: 2018-03-18 01:05:20
*/
#include <iostream>
#include <algorithm>
using namespace std;

typedef unsigned long long ll;
const int maxn=(int)2e5+5;
int n;
ll a[maxn],b[maxn],c[maxn];

void merge (ll *p,ll mod) {   //在给定的mod下归并排序
	int i,j,k,m;
	for(i=1;i<=n;i++) {
		c[i]=p[i];
		if(p[i]>=mod)c[i]=p[i]%mod;
	}
	c[n+1]=mod<<1;
	sort(c+1,c+1+n);
	for(int i=1;i<=n;i++)p[i]=c[i];
}

ll bigthan (ll m) {             //大于m的数对对数
	int i,j=n;ll ans=0;
	for (i=1;i<=n;i++) {
		while ((a[i]+b[j])>=m&&j>0) j--;
		ans+=n-j;
	}
	return ans;
}

bool get (ll mod) {               //考虑mod位是否为1
	merge (a,mod<<1);
	merge (b,mod<<1);
	ll ans = bigthan(mod) + bigthan(3*mod) - bigthan(mod<<1);
	if ( ans%2 ) return true;
	return false;
}

int main () 
{
	int i;
	ll mod,ans;
	cin>>n;
	for(i=1;i<=n;i++) cin>>a[i];
	for(i=1;i<=n;i++) cin>>b[i];
	sort(a+1,a+n+1);sort(b+1,b+n+1);
	ans=0;mod=(ll)1<<28;
	while(mod) {
		if (get(mod)) 
			ans+=mod;
		mod=mod>>1;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 4992
#include<iostream>
#include<string>

using namespace std;

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

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

int main(){
  int n,m; cin>>n>>m;
  cout << n*(n-1)/2 + m*(m-1)/2 << endl;
}

Measured memory_bytes: 3624
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String a = sc.next();
		String b = sc.next();
		if(a.equals("H")) {
			System.out.println(b.equals("H")? "H" : "D");
		} else {
			System.out.println(b.equals("D")? "H" : "D");
		}
	}
}

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

typedef long long ll;
using namespace std;

# define MOD 1000000007

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int m1, d1, m2, d2;
    cin >> m1 >> d1 >> m2 >> d2;
    cout << ((m2 > m1) || (m1 == 12 && d1 == 31)) << "\n";
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
  int s,w;
  scanf("%d %d", &s ,&w);
  if(!(s >= 1 && s <= 100 && w >= 1 && w <= 100))
    return 1;
  if(w >= s)
  {
    printf("unsafe\n");
  }
  else
    printf("safe\n");
}

Measured memory_bytes: 1660
#include <bits/stdc++.h>
using namespace std;
char s[500002];
struct f{
    int ft[500002];
    void update(int i, int v){
        for(;i<=500000;i+=(i&-i)) ft[i] += v;
    }
    int query(int i){
        int ans = 0;
        for(;i>0;i-=(i&-i)) ans+=ft[i];
        return ans;
    }
}ft[26];

int main(){
    int n;
    scanf("%d", &n);
    scanf("%s", s+1);
    for(int i=1;i<=n;i++){
        int c = s[i]-'a';
        ft[c].update(i, 1);
    }
    int q;
    scanf("%d", &q);
    for(int i=1;i<=q;i++){
        int t;
        scanf("%d" ,&t);
        if(t == 1){
            int x;
            scanf("%d%s", &x, s);
            for(int j=0;j<26;j++){
                int q = ft[j].query(x) - ft[j].query(x-1);
                if(q == 1){
                    ft[j].update(x, -1);
                    break;
                }
            }
            ft[s[0]-'a'].update(x, 1);
        }
        else{
            int l, r;
            scanf("%d%d", &l, &r);
            int ans = 0;
            for(int j=0;j<26;j++){
                int q = ft[j].query(r) - ft[j].query(l-1);
                if(q > 0) ans++;
            }
            printf("%d\n", ans);
        }
    }
}

Measured memory_bytes: 51584
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;

ll a[222222];
ll suf[222222];
int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n; cin>>n;
	for(int i=0;i<=n;i++)
	{
		cin>>a[i];
	}
	suf[n]=a[n];
	for(int i=n-1;i>=0;i--) suf[i]=a[i]+suf[i+1];
	if(n==0)
	{
		if(a[0]==1) cout<<1<<'\n';
		else cout<<-1<<'\n'; 
		return 0;
	}
	if(a[0]!=0) {cout<<-1<<'\n'; return 0;}
	ll ans=1;
	ll cur=1;
	ll preans=1;
	for(int i=1;i<=n;i++)
	{
		ll newcur=cur*2;
		if(newcur<a[i])
		{
			cout<<-1<<'\n'; return 0;
		}
		ans+=a[i];
		newcur-=a[i];
		cur=newcur;
		cur=min(newcur,suf[i+1]);
		if(i==n) cur=0;
		ans+=cur;
		//cerr<<i<<' '<<ans<<' '<<preans<<'\n';
		preans=ans;
	}
	cout<<ans<<'\n';
}


Measured memory_bytes: 5184
import java.util.Scanner;

public class Main {
    public static int h, w;
    public static int[][] map, checkMap;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()) {
            h = sc.nextInt();
            if (h == 0) {
                break;
            }
            w = 5;
            map = new int[h][5];
            checkMap = new int[h][5];
            for (int i = 0; i < h; i++) {
                for (int j = 0; j < 5; j++) {
                    map[i][j] = sc.nextInt();
                }
            }
            System.out.println(point());
        }
    }

    public static int point() {
        int p = 0;
        while (true) {
            arrayDump(map);
            for (int i = 0; i < h; i++) {
                checkLine(i);
            }
            arrayDump(checkMap);
            int res = calc();
            drop();
            arrayDump(map);
            p += res;
            if (res == 0) {
                break;
            }
        }
        return p;
    }

    public static void drop() {
        for (int i = 0; i < h; i++) {
            for (int j = h - 2; j >= 0; j--) {
                for (int k = 0; k < w; k++) {
                    if (map[j + 1][k] == 0) {
                        map[j + 1][k] = map[j][k];
                        map[j][k] = 0;
                    }
                }
            }
        }
    }

    public static int calc() {
        int p = 0;
        for (int i = 0; i < map.length; i++) {
            for (int j = 0; j < map[0].length; j++) {
                if (checkMap[i][j] == 1) {
                    p += map[i][j];
                    checkMap[i][j] = 0;
                    map[i][j] = 0;
                }
            }
        }
        return p;
    }

    public static void checkLine(int i) {
        int chain = 0;
        int current = 0;
        for (int j = 0; j < w; j++) {
            if (map[i][j] != current) {
                if (chain >= 3) {
                    for (int rj = 0; rj < chain; rj++) {
                        checkMap[i][j - rj - 1] = 1;
                    }
                }
                current = map[i][j];
                chain = 1;
                continue;
            }
            chain ++;
        }
        if (chain >= 3) {
            for (int rj = 0; rj < chain; rj++) {
                checkMap[i][w - rj - 1] = 1;
            }
        }
    }

    public static void arrayDump(int[][] list) {
        return;
        // for (int i = 0; i < list.length; i++) {
        //     for (int j = 0; j < list[0].length; j++) {
        //         System.out.print(list[i][j] + ", ");
        //     }
        //     System.out.println();
        // }
        // System.out.println();
    }

}

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

using namespace std;
int main()
{
    int a,b,n,ans;
    cin >> n;
    a = 1;
    b = 1;
    ans = 0;
    while(a<10){
        b = 1;
        while(b<10){
            if(a*b==n){
                ans = 1;
                break;
            }
            //cout << a*b;
            //cout << " ";
            b++;
        }
        a++;
    }
    if(ans==1){
        cout << "Yes";
    }
    else{
        cout << "No";
    }
}

Measured memory_bytes: 256
let rec input n =
		if n = 0
		then []
		else Scanf.scanf "%d %d\n" (fun x y -> (x,y)) :: input (n - 1)

let solve lst =
	let rec solve_loop before lst = match lst with
		| [] -> let(a,b) = before in a + b
		| first :: xs ->
			let (x,y) = first in
			let (a,b) = before in
			let ratio = max ((a-1)/x+1) ((b-1)/y+1) in
				solve_loop (x*ratio,y*ratio) xs
	in
		solve_loop (1,1) (List.rev lst)

let () =
	Scanf.scanf "%d\n" (fun x -> x) |> input |> solve |> Printf.printf "%d"


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define vcout(v) rep(i,v.size()) cout << v[i] << " "; cout << endl
#define mcout(m) rep(j,m.size()){vcout(m[j]);}
const ll MOD = 1e9 + 7;
class UnionFind {
public:
    vector <ll> par; // 各元の親を表す配列
    vector <ll> siz; // 素集合のサイズを表す配列(1 で初期化)

    // Constructor
    UnionFind(ll n){
    	rep(i,n){
    		par.push_back(i); // 初期では親は自分自身
    		siz.push_back(1);
    	}
    }

    // Member Function
    // Find
    ll root(ll x) { // 根の検索
        while (par[x] != x) {
            x = par[x] = par[par[x]]; // x の親の親を x の親とする
        }
        return x;
    }

    // Union(Unite, Merge)
    bool merge(ll x, ll y) {
        ll rx = root(x);
        ll ry = root(y);
        if (rx == ry) return false;
        // merge technique（データ構造をマージするテク．小を大にくっつける）
        if (siz[rx] < siz[ry]) swap(rx, ry);
        siz[rx] += siz[ry];
        par[ry] = rx;
        return true;
    }

    bool issame(ll x, ll y) { // 連結判定
        return root(x) == root(y);
    }

    ll size(ll x) { // 素集合のサイズ
        return siz[root(x)];
    }
	
};


void mainsolve(){

	ll n,m,k;
	cin >> n >> m >> k;

	UnionFind uf(n);
	vector<ll> res(n);

	rep(i,m){
		ll a,b;
		cin >> a >> b;
		--a; --b;
		uf.merge(a,b);
		res[a]--; res[b]--;
	}

	rep(i,k){
		ll c,d;
		cin >> c >> d;
		--c; --d;
		if(uf.issame(c,d)){
			res[c]--; res[d]--;
		}
	}

	rep(i,n){
		res[i] += uf.size(i);
		cout << res[i]-1 << " ";
	}


	cout << endl;
	return;
}

int main(){
	
	//ll TC;cin>>TC;rep(I,TC){cout<<"case:"<<I+1<<"---"<<endl; // comment out!
		mainsolve();
	//} // comment out!
	return 0;
}

Measured memory_bytes: 3436
N = int(input())
a = list(map(int,input().split()))
ans = 1
for i in range(N):
    if a[i] == 0:
        ans = 0
if ans != 0:
    for i in range(N):
        ans *= a[i]
        if ans > 10**18:
            ans = -1
            break

print(ans)

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

int main(){
    ll x,y,a,b,c;
    ll pc,qc,rc,temp,ans,pdai,qdai,rdai;
    ans = 0;
    pc = 0;
    qc = 0;
    rc = 0;
    cin >> x >> y >> a >> b >> c;
    vector<ll> p;
    vector<ll> q;
    vector<ll> r;
    for(ll i = 0; i < a; i++){
        cin >> temp;
        p.push_back(temp);
    }
  
    for(ll i = 0; i < b; i++){
        cin >> temp;
        q.push_back(temp);
    }
    for(ll i = 0; i < c; i++){
        cin >> temp;
        r.push_back(temp);
    }
  
    sort(p.begin(), p.end(), greater<ll>());
    sort(q.begin(), q.end(), greater<ll>());
    sort(r.begin(), r.end(), greater<ll>());
  
    pdai = p[0];
    qdai = q[0];
    rdai = r[0];
  
    for(ll i = 0; i < (x+y);i++){
        temp = max({pdai,qdai,rdai});
        ans += temp;
        if(temp == pdai){
            pc++;
            if(pc >= x) pdai = -1;
            else pdai = p[pc];
        }
        else if(temp == qdai){
            qc++;
            if(qc >= y) qdai = -1;
            else qdai = q[qc];
        }
        else{
            rc++;
            //if(rc >= x) rdai = -1;
            rdai = r[rc];
        }
    }
    cout << ans << endl;




}

Measured memory_bytes: 3316
void main(){
  import std.stdio, std.string, std.conv, std.algorithm;
  import std.typecons;

  int n; rd(n);
  auto data=new int[][](3, 0);
  foreach(i; 0..3) data[i]=readln.split.to!(int[]);

  auto a=new Tuple!(int, int)[](0);
  foreach(i; 0..3){
    foreach(e; data[i]) a~=Tuple!(int, int)(e, i);
  }
  sort!"a[0]==b[0] ? a[1]>b[1] : a[0]<b[0]"(a);
  long x=0, y=0, z=0;
  foreach(e; a){
    if(e[1]==0) x++;
    else if(e[1]==1) y+=x;
    else z+=y;
  }
  writeln(z);
}

void rd(T...)(ref T x){
  import std.stdio, std.string, std.conv;
  auto l=readln.split;
  assert(l.length==x.length);
  foreach(i, ref e; x){
    e=l[i].to!(typeof(e));
  }
}


Measured memory_bytes: 15452
#入力:N,M(int:整数)
def input2():
	return map(int,input().split())

#入力:[n1,n2,...nk](int:整数配列)
def input_array():
	return list(map(int,input().split()))

class UnionFind():
	"""docstring for UnionFind"""
	def __init__(self, n):
		self.parents = [-1]*n

	def find(self,x):
		if self.parents[x] < 0: #自分が親である時
			return x
		else: #自分が子供である時
			self.parents[x]=self.find(self.parents[x])
			return self.parents[x]

	def union(self,x,y):
		# 各要素の親要素を返す
		x=self.find(x)
		y=self.find(y)

		if x==y:
			return
		if self.parents[x] > self.parents[y]:
			x,y=y,x

		self.parents[x]+=self.parents[y]
		self.parents[y]=x
		# print(self.parents)
n,m=input2()
AB=[input_array() for _ in range(m)]


uf = UnionFind(n)
for ab in AB:
	a=ab[0]
	b=ab[1]
	uf.union(a-1,b-1)

ans=0
for i in uf.parents:
	if i < 0:
		ans+=1
print(ans-1)

Measured memory_bytes: 29112
package main

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

const (
	initialBufSize = 100000
	maxBufSize     = 10000000
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wt = bufio.NewWriter(os.Stdout)
)

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

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, initialBufSize), maxBufSize)
	defer wt.Flush()

	n, k := nextInt(), nextInt()

	// kの倍数の個数
	x := n / k
	// kで割ってk/2余る数の個数
	y := (n + (k / 2)) / k

	var ans int
	if k%2 == 0 {
		ans = x*x*x + y*y*y
	} else {
		ans = x * x * x
	}
	puts(ans)
}


Measured memory_bytes: 640
package main

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

func main() {
	var s string
	fmt.Scan(&s)

	for i := 0; i < len(s) - 1; i++ {
		if s[i : i + 1] != s[i + 1 : i + 2] {
			fmt.Println("Yes")
			return
		}
	}
	fmt.Println("No")
	
}

func Max(a, b int) int {
	if a > b {
		return a
	}
	return b
}
 
func MaxInts(n ...int) int {
	max := n[0]
	for _, v := range n[1:] {
		if v > max {
			max = v
		}
	}
	return max
}
 
type Reader struct {
	r    *bufio.Reader
	size int
	sep  string
}
 
func NewReader() *Reader {
	size := 4096
	return &Reader{
		r:    bufio.NewReaderSize(os.Stdin, size),
		size: size,
		sep:  " ",
	}
}
 
func (rdr *Reader) ReadLine() string {
	buf := make([]byte, 0, rdr.size)
	for {
		line, isPrefix, err := rdr.r.ReadLine()
		if err != nil {
			panic(err)
		}
		buf = append(buf, line...)
		if !isPrefix {
			break
		}
	}
	return string(buf)
}
 
func (rdr *Reader) ReadStrs() []string {
	return strings.Split(rdr.ReadLine(), rdr.sep)
}
 
func (rdr *Reader) ReadInts() []int {
	a := rdr.ReadStrs()
	b := make([]int, len(a))
	for i, v := range a {
		b[i], _ = strconv.Atoi(v)
	}
	return b
}


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

using _i64 = int64_t;
using _u64 = uint64_t;
using _f64 = double;

#define _for(i, start, end) for(_i64 i = (_i64)start; i < (_i64)end; ++i)
#define _rep(i, number) _for(i, 0, number)
#define _foreach(e, data) for(auto& e : data)
#define _all(data) data.begin(), data.end()

template<typename type>
_i64 _size(const type& data) { return static_cast<_i64>(data.size()); }
template<typename type, size_t size>
_i64 _size(const type (&)[size]) { return static_cast<_i64>(size); }

enum _flag : bool { able = true, disable = false };

struct _time {
    _time(_flag flag) { check = flag; if(!check) { return; } gettime(start); }
    ~_time() {
        if(!check) { return; }; gettime(end);
        _i64 elapse = chrono::duration_cast<chrono::milliseconds>(end - start).count();
        cout << endl << "Time: " << elapse << " ms" << endl;
    }
    private:
    using _timer = chrono::time_point<chrono::system_clock>;
    _timer start, end; bool check;
    void gettime(_timer& time) { time = chrono::system_clock::now(); }
};

struct _ini { _ini() { ios::sync_with_stdio(false); cin.tie(nullptr); } } _ini;

_i64 _gcd(_i64 a, _i64 b) {
    return (max(a, b) % min(a, b) != 0 ? _gcd(min(a, b), max(a, b) % min(a, b)) : min(a, b));
}

int main() {
    {
        _time time(disable);
        _i64 n;
        vector<_i64> ans(1000000);
        ans[1] = 0; ans[2] = 1; ans[3] = 2; ans[4] = 2;
        for(_i64 i = 5; i < 1000000; i += 6) {
            for(_i64 j = 3; j <= sqrt(i) + DBL_EPSILON; j += 2) {
                if(i % j == 0) { ans[i] = ans[i - 1]; break; }
            }
            if(!ans[i]) { ans[i] = ans[i - 1] + 1; }
            ans[i + 1] = ans[i];
            for(_i64 j = 3; j <= sqrt(i + 2) + DBL_EPSILON; j += 2) {
                if((i + 2) % j == 0) { ans[i + 2] = ans[i + 1]; break; }
            }
            if(!ans[i + 2]) { ans[i + 2] = ans[i + 1] + 1; }
            ans[i + 3] = ans[i + 2];
            ans[i + 4] = ans[i + 3];
            ans[i + 5] = ans[i + 4];
        }
        while(cin >> n) { cout << ans[n] << endl; }
    }
    return 0;
}


Measured memory_bytes: 10632
open Printf open Scanf
open Array

let print_list f ls = List.iter (fun v -> printf "%s " @@ f v) ls; print_newline ()

(* rosetta code *)
let count_substring str sub =
  let sub_len = String.length sub in
  let len_diff = (String.length str) - sub_len
  and reg = Str.regexp_string sub in
  let rec aux i n =
    if i > len_diff then n else
      try
        let pos = Str.search_forward reg str i in
        aux (pos + sub_len) (succ n)
      with Not_found -> n
  in
  aux 0 0

let () = scanf " %d" @@ fun n ->
  let arr = init n (fun _ -> scanf " %s" @@ fun s -> s)
  in
  let kba,kbx,kxa,krest = fold_left (fun (kba,kbx,kxa,krest) s ->
    let bx = s.[0] = 'B' in
    let xa = s.[String.length s-1] = 'A' in
    let ab = bx && xa in
    let kba = if ab then kba + 1 else kba in
    let kbx = if not ab then (
      if bx then kbx+1 else kbx
    ) else kbx in
    let kxa = if not ab then (
      if xa then kxa+1 else kxa
    ) else kxa in
    let krest = krest + count_substring s "AB"
    in
    (kba,kbx,kxa,krest)
  ) (0,0,0,0) arr in
  let hoge =
    if kba >= 1 then (
      let pair_ba = kba - 1 in
      let res = 0 in
      let res,kbx =
        if kbx > 0 then res+1,kbx-1 else res,kbx in
      let res,kxa =
        if kxa > 0 then res+1,kxa-1 else res,kxa in
      pair_ba + res + min kbx kxa
    ) else (
      min kbx kxa
    ) in
  print_int @@ krest + hoge




Measured memory_bytes: 4864
import math

A, B = input().split()
A = int(A)
sei = int(B[0])
syou = int(B[2]+B[3])
#print(sei,syou)
B = sei*100 + syou
###print(B)
#print(A*B)
ans = (A*B) // 100 




print(ans)



Measured memory_bytes: 9108
#include <bits/stdc++.h>
#ifdef DEMETRIO
#define deb(...) fprintf(stderr,__VA_ARGS__)
#define deb1(x) cerr << #x << " = " << x << endl
#else
#define deb(...) 0
#define deb1(x) 0
#endif
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define fore(i,a,b) for(int i=a,ThxDem=b;i<ThxDem;++i)
#define SZ(x) ((int)x.size())
using namespace std;
typedef long long ll;

ll x[100005];
int n;

ll doit(ll k){
	fore(i,0,n)k=k/x[i]*x[i];
	return k;
}

int main(){
	scanf("%d",&n);
	fore(i,0,n)scanf("%lld",x+i);
	ll s=2,e=1LL<<60;
	while(e-s>1){
		ll m=(s+e)/2;
		if(doit(m-1)>=2)e=m;
		else s=m;
	}
	if(doit(s)!=2){puts("-1");return 0;}
	ll r0=s;
	s=2;e=1LL<<60;
	while(e-s>1){
		ll m=(s+e)/2;
		if(doit(m-1)>2)e=m;
		else s=m;
	}
	printf("%lld %lld\n",r0,s-1);
	return 0;
}

Measured memory_bytes: 1152
#include<stdio.h>
#define INF 2140000000
#define N 102
#define white 0
#define gray 1
#define black 2

//最小全域木はそれぞれの辺の最小の総和を計算するプログラム

int color[N],p[N],d[N];      //ｐは親、ｄは距離

void prim(int a[][N],int n){
  int i,mincost,u;

  for(i=0;i<n;i++){           //色と距離を初期化
    color[i]=white;
    d[i]=INF;
  }

  d[0]=0;                  //配列の０から考えるので、d[0]の距離は０で親はいないのでp[0]はー１
  p[0]=-1;

  while(1){
    mincost=INF;

    for(i=0;i<n;i++){             //辺の中で一番小さいものを探す
      if(color[i]!=black && d[i]<mincost){
	mincost=d[i];
	u=i;
      }
    }

    if(mincost==INF) break;     //すべての探索が終わっている場合、プログラムを終了させる
    
    color[u]=black;          //移動した先の頂点を黒にする

    for(i=0;i<n;i++){
      if(color[i]!=black && a[u][i]!=-1 && d[i]>a[u][i]){  //辺があり、一番小さいものを探し出す
	d[i]=a[u][i];
	p[i]=u;
	color[i]=gray;
      }
    }
  }
}

void print(int a[][N], int n){
  int sum=0,i;
  for(i=1;i<n;i++){    //0は距離がないので、１から始まる。
    sum+=a[i][p[i]];  //２次配列が対称になっているため
  }
  printf("%d\n",sum);
}

int main(){
  int a[N][N],n,i,j,result;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      scanf("%d",&a[i][j]);
    }
  }

  prim(a,n);
  print(a,n);

  return 0;
}



Measured memory_bytes: 2104
#include<iostream>
#include<stack>
using namespace std;

int main(){
  stack<int> st;
  int n,a;

  while(cin>>n){
    if(n!=0){
      st.push(n);
    }
    else{
      a = st.top();
      cout << a<<endl;
      st.pop();
    }
  }
  return 0;
}

Measured memory_bytes: 0
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

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

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

func main() {
	sc.Split(bufio.ScanWords)
	N, M, Q := getInt(), getInt(), getInt()
	n := make([][]int, N+1)
	for i := 0; i <= N; i++ {
		n[i] = make([]int, N+1)
	}
	for i := 0; i < M; i++ {
		l, r := getInt(), getInt()
		n[l][r]++
	}
	// for i := 0; i <= N; i++ {
	// 	out(n[i])
	// }
	// out("----")
	for i := 1; i <= N; i++ {
		for j := i + 1; j <= N; j++ {
			n[i][j] += n[i][j-1]
		}
	}
	// for i := 0; i <= N; i++ {
	// 	out(n[i])
	// }
	var dp [550][550]int
	var calced [550][550]bool

	w := bufio.NewWriter(os.Stdout)
	defer w.Flush()

	for i := 0; i < Q; i++ {
		p, q := getInt(), getInt()
		if calced[p][q] == true {
			fmt.Fprintln(w, dp[p][q])
			continue
		}
		ans := 0
		// out("pq", p, q)
		for j := p; j <= q; j++ {
			// out(j, j, n[j][p-1], n[j][q])
			ans += n[j][q] - n[j][p-1]
		}
		// out("-----", ans)
		fmt.Fprintln(w, ans)
		calced[p][q] = true
		dp[p][q] = ans
	}
}


Measured memory_bytes: 8064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pi = pair<int, int>;
using pll = pair<ll, ll>;
constexpr int INF = 0x3f3f3f3f; constexpr ll LLINF = 0x3f3f3f3f3f3f3f3f;
#define db(x) { cerr << #x << " = " << x << endl; }
template<class RIt> void dbarr(RIt frs, RIt lst){ cerr << "arr: "; for(int i = 0; i < (int)(lst-frs); i++) cerr << frs[i] << " \n"[i==(int)(lst-frs)-1]; }
#define all(x) begin(x), end(x)
#define pb push_back
#define eb emplace_back
#define mpr make_pair
#define fs first
#define sn second

int main() {
	cin.tie(0)->sync_with_stdio(0);
    set<char> ss;
    string s; cin >> s;
    for(char c : s) ss.insert(c);
    for(char i = 'a'; i <= 'z'; i++){
        if(ss.find(i) == ss.end()){
            cout << i << "\n";
            return 0;
        }
    }
    cout << "None\n";
}



Measured memory_bytes: 3756
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
template <class T> void chmin(T &a, const T &b) noexcept { if (b < a) a = b; }
template <class T> void chmax(T &a, const T &b) noexcept { if (a < b) a = b; }
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cout << H << " "; debug_out(T...); }
#ifdef _DEBUG
  #define debug(...) debug_out(__VA_ARGS__)
#else
  #define debug(...) 
#endif

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  int n;
  string str;
  cin >> n >> str;
  vector<int> cntw(n), cnte(n);
  rep(i,n) {
    if (str[i] == 'W') cntw[i]++;
    if (i < n-1) cntw[i+1] += cntw[i];
    // debug(cnt[i]);
  }
  for (int i = n-1; i >= 0; --i) {
    if (str[i] == 'E') cnte[i]++;
    if (i > 0) cnte[i-1] += cnte[i];
  }
  int ans = 1001001001;
  rep(i,n) {
    chmin(ans, cntw[i]+cnte[i]-1);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 2964
#ifdef DEBUG
#include <ctime>
#endif
#include <cstdio>
#include <cstring>
int main(void)
{
	#ifdef DEBUG
//		freopen("_in","r",stdin);
		clock_t startTime=clock();
	#endif
	int i,N=102,p[102],x;
	memset(p,0,sizeof(p));

	p[4]=1;
	p[7]=1;
	for(i=0;i<N;i++)
	{
		if(p[i]==1)
		{
			if(i+4<N)p[i+4]=1;
			if(i+7<N)p[i+7]=1;
		}
	}
	scanf("%d",&x);
	printf("%s\n",p[x]?"Yes":"No");

	#ifdef DEBUG
		printf("\t[RUNTIME= %3dms]\n",clock()-startTime);
	#endif
	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
using namespace std;
typedef long long ll;
typedef pair<int, int>P;

signed main() {
	ll n, a, b; cin >> n >> a >> b;
	printf("%lld\n", max(0LL, (n - 1)*b + a - (n - 1)*a - b + 1));
}

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

using pll = pair<long long, long long>;

int main() {
    int N; cin >> N;
    vector<pll> pos(N);
    for (int i = 0; i < N; ++i) cin >> pos[i].first >> pos[i].second;
    
    int par = (abs(pos[0].first) + abs(pos[0].second)) % 2;
    for (int i = 0; i < N; ++i) {
        int par2 = (abs(pos[i].first) + abs(pos[i].second)) % 2;
        pos[i] = pll(pos[i].first + pos[i].second, pos[i].first - pos[i].second);
        if (par2 != par) {
            cout << -1 << endl;
            return 0;
        }
    }
    
    vector<long long> d;
    for (int i = 30; i >= 0; --i) d.push_back(1LL<<i);
    if (par % 2 == 0) d.push_back(1);
    cout << d.size() << endl;
    for (int j = 0; j < d.size(); ++j) cout << d[j] << " ";
    cout << endl;
        
    for (int i = 0; i < N; ++i) {
        int xdir, ydir;
        long long xsum = 0, ysum = 0;
        for (int j = 0; j < (int)d.size(); ++j) {
            if (xsum <= pos[i].first) xdir = 1, xsum += d[j];
            else xdir = -1, xsum -= d[j];
            if (ysum <= pos[i].second) ydir = 1, ysum += d[j];
            else ydir = -1, ysum -= d[j];
            
            if (xdir == 1 && ydir == 1) cout << "R";
            else if (xdir == 1 && ydir == -1) cout << "U";
            else if (xdir == -1 && ydir == -1) cout << "L";
            else cout << "D";
        }
        cout << endl;
    }
}

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


signed main(){
	int N;
	int ans=0;
	cin>>N;
	vector<int> sum(N);
	int a;
	cin >> a;
	sum.at(0)=a;
	for(int i=1;i<N;i++){
		cin >> a;
		sum.at(i)=sum.at(i-1)+a;
	}
	
	sort(sum.begin(),sum.end());
	reverse(sum.begin(),sum.end());
	
	int tmp=1;
	if(sum.at(0)==0)ans++;
	for(int i=1;i<N;i++){
		if(sum.at(i)==0)ans++;
		if(sum.at(i)==sum.at(i-1))tmp++;
		else{
			ans+=(tmp*(tmp-1))/2;
			tmp=1;
		}
	}
	ans+=(tmp*(tmp-1))/2;
	cout<<ans<<endl;
	
}



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

int main() {
	int n,x;
	while(cin>>n>>x){
		int a[10000][100]={0,0},last=0,last1=0;
		for(int i=0;i<n;i++){
			for(int j=0;j<x;j++){
				cin>>a[i][j];
				cout<<a[i][j]<<" ";
				last+=a[i][j];
				if(j==x-1){
					cout<<last<<endl;
					last1+=last;
					last=0;
				}
			}
		}
		for(int i=0;i<x;i++){
			for(int j=0;j<n;j++){
				last+=a[j][i];
				if(j==n-1){
					cout<<last<<" ";
					last=0;
				}
			}
		}
		cout<<last1<<endl;
		last1=0;
	}
	return 0;
}


Measured memory_bytes: 5072
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;




int main(){

	int a,b,c;

	scanf("%d %d %d",&a,&b,&c);

	if(a+b+c >= 22){

		printf("bust\n");

	}else{

		printf("win\n");
	}

	return 0;
}


Measured memory_bytes: 256
import pprint
import copy
import itertools as it
H, W, K = map(int, input().split())
M__ = []
M_ = []
M = []
for _ in range(H):
    M__.append(list(input()))
rows = []
for i in range(H):
    rows += list(it.combinations(range(H), i))
cols = []
for i in range(W):
    cols += list(it.combinations(range(W), i))

def fillrow(n):
    global M_
    M_[n] = ['x' for _ in range(W)]

def fillcol(n):
    global M
    for i in range(H):
        M[i][n] = 'x'

ans = 0
for row in rows:
    M_ = copy.deepcopy(M__)
    for v in row:
        fillrow(v)

    for col in cols:
        M = copy.deepcopy(M_)
        for v in col:
            fillcol(v)
        if sum([M[i].count('#') for i in range(H)]) == K:
            ans += 1

print(ans)


Measured memory_bytes: 10036
from collections import Counter
n = int(input())
a = Counter(list(map(int, input().split())))
c = []
for i, j in a.items():
    if j >= 2:
        for _ in range(j//2):
            c.append(i)
c.sort(reverse = True)
print(c[0]*c[1] if len(c)>=2 else 0)

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


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

    vector<int> A(M);

    for(int i = 0; i < M;i++){
        cin >> A[i];
    }

    for(int i = 0; i < M; i++){
        N -= A[i];
    }

    if(N >= 0) cout << N << endl;
    else cout << -1 << endl;

}


Measured memory_bytes: 3648
def bmi(h, w)
  w / (h * 0.01)**2
end

while line = gets
  n = line.chomp.to_i
  break if n == 0

  min_i = Float::INFINITY
  min_diff = Float::INFINITY

  n.times do
    i, h, w = gets.chomp.split.map(&:to_i)
    bmi = bmi(h, w)
    diff = (bmi - 22).abs

    if diff == min_diff
      min_i = [i, min_i].min
    elsif diff < min_diff
      min_i = i
      min_diff = diff
    end
  end

  puts min_i
end 

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

int main() {
  int n;
  cin >> n;
  set<string> s;
  for(int i = 0; i < n; ++i){
    string helper; cin >> helper;
    s.insert(helper);
  }
  cout << s.size() << endl;
}

Measured memory_bytes: 19120
#include<stdio.h>
#include<string.h>
int main()
{
  int i,o,a,n,sum;
  char S[1024];

  while(1){
    scanf("%s",S);
    if(S[0]=='#')break;
    sum=0;o=1;a=0;n=1;
    i=strlen(S)-1;
    if(S[i]=='h'){
      sum=0;
      i-=5;
    }
    else{
      sum=90;
      i-=4;
    }
    while(i>-1){
      o*=2;
      sum*=2;
      if(S[i]=='h'){
	sum-=90;
	i-=5;
      }
      else{
	sum+=90;
	i-=4;
      }
    }
    while(sum%2==0 && o!=1){
      sum/=2;
      o/=2;
    }
    if(o==1)printf("%d\n",sum);
    else printf("%d/%d\n",sum,o);
  }
  return 0;
}

Measured memory_bytes: 536
#include<bits/stdc++.h>
#define ll long long int
#define pb push_back
#define PB push
#define N 100005
#define nd second
#define st first
#define ii pair<ll,ll>
#define mp make_pair
#define p_q priority_queue
using namespace std;

ll n, a;

int main(){
	cin >> n;
	while(n--){
		cin >> a;
		if(a % 2 == 0){
			if(a%3 != 0 && a%5 != 0){
				cout << "DENIED" << endl;
				return 0;
			}
		}
	}
	cout << "APPROVED" << endl;

return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
        long N = sc.nextInt();
        long K = sc.nextInt();
        long cnt =0;
        long sho =0;
        long kari;
        if(K==0)
          cnt = N*N;
        else{
          for(long b=K+1;b<=N;b++){
            sho = N/b;
            kari = (b-K)*sho;
            if(N<sho*b+K)
              cnt += kari;
            else
              cnt += kari + N + 1 -(sho * b) - K;
          }
        }
        System.out.println(cnt);  
	}
}

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

int n;
string s;

int main() {
    cin >> n >> s;
    unordered_map<char, vector<int>> m;
    rep(i, n) m[s[i]].push_back(i);
    int ans = 0;
    for (char i = '0'; i <= '9'; i++) {
        auto x = m[i].begin();
        if (x == m[i].end()) continue;
        for (char j = '0'; j <= '9'; j++) {
            auto y = upper_bound(m[j].begin(), m[j].end(), *x);
            if (y == m[j].end()) continue;
            for (char k = '0'; k <= '9'; k++) {
                auto z = upper_bound(m[k].begin(), m[k].end(), *y);
                if (z != m[k].end()) ans++;
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 512
//K-OS WITH THE OCDE

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <stack>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <deque>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <climits>

using namespace std;

typedef long long int ll;
typedef long double db;


#define TEST ll t; cin>>t; while(t--)
#define vell vector<ll>
#define pl pair<ll,ll>
#define all(v) v.begin(),v.end()
#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#define dbg(x)  cerr << #x << ": "<< x <<endl
#define dbg2(x,y) cerr<< #x <<": "<< x <<" || "<< #y << ": " << y << endl

#define endl "\n"
#define MAX 1e18
#define MIN INT_MIN
#define mod 1000000007



void solve()
{
     ll x;
     cin >> x;
     if(x >= 30)
     	cout << "Yes";
     else
     	cout << "No";
}

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



Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
/* 答えをにぶたんで狭めていく系 */

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))

#define INF 2e9
#define INF_LL 1LL<<60
#define ll long long

typedef pair<ll, ll> P;

int main(){
    ll n, k;
    cin >> n >> k;
    vector<ll> a(n);
    vector<ll> f(n);

    REP(i, n) cin >> a[i];
    REP(i, n) cin >> f[i];

    sort(a.begin(), a.end());
    sort(f.rbegin(), f.rend());

    ll up = 1e12+1;
    ll low = -1;

    while(up - low > 1) {
        ll x = (up + low) / 2;
        ll tmp = 0;
        REP(i, n) {
            tmp += max(a[i] - (x/f[i]), 0ll);
        }
        if(tmp <= k) {
            /* いける */
            up = x;
        } else {
            /* いけない */
            low = x;
        }
    }

    cout << up << endl;

    
    return 0;
}


Measured memory_bytes: 3328
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn is_palind(s: &[char]) -> bool{

    for i in 0..s.len()/2{
        if s[i] != s[s.len()-1-i]{
            return false;
        }
    }
    return true;
}

fn main(){
    let s = read_as_string();
    let sv = s.chars().collect::<Vec<char>>();
    if !s.contains('x'){
        if is_palind(&sv){
            println!("0");
            return;
        }else{
            println!("-1");
            return;
        }
    }else{
        let mut ans: u64 = 0;
        let (mut left, mut right) = (0, sv.len()-1);

        while left < right{
            if sv[left] == sv[right]{
                left += 1;
                right -= 1;
            }else if sv[left] == 'x'{
                left += 1;
                ans += 1;
            }else if sv[right] == 'x'{
                right -= 1;
                ans += 1;
            }else{
                println!("-1");
                return;
            }
        }
        println!("{}", ans);
    }
}


Measured memory_bytes: 4352
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {
	public static void main(String[] args) {
		InputStreamReader isr = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(isr);
		try {
			String[] list = br.readLine().split(" ");
			int a = Integer.parseInt(list[0]);
			int b = Integer.parseInt(list[1]);
			int d = a / b;
			int r = a % b;
			double f = (double) a / b;
			System.out.println(d + " " + r + " " + String.format("%.5f", f));

		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}

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

if K==0:
    ans=0
    for a in A:
        ans+=a^0
    print(a)
    exit()


l = len(bin(K))-2
s0 = [0 for i in range(l)]
s1 = [0 for i in range(l)]
for a in A:
    S = bin(a)[2:].zfill(l)
    for i in range(1,l+1):
        if S[-i]=='0':
            s0[i-1]+=1
        else:
            s1[i-1]+=1


res0 = ['0',s1[l-1]*(2**(l-1))]
res1 = ['1',s0[l-1]*(2**(l-1))]
n = l-2
Kstr=bin(K)[2:]

while n>=0:
    # res0
    tmp0 = []
    if (res0[0]+'0').ljust(l,'0') <= Kstr:
        tmp0.append([res0[0]+'0',res0[1]+s1[n]*(2**n)])
    if (res1[0]+'0').ljust(l,'0') <= Kstr:
        tmp0.append([res1[0]+'0',res1[1]+s1[n]*(2**n)])
    tmp0.sort(key=lambda x:x[0])
    tmp0.sort(key=lambda x:x[1],reverse=True)
    nextres0 = tmp0[0]

    # res1
    tmp1 = []
    if (res0[0]+'1').ljust(l,'0') <= Kstr:
        tmp1.append([res0[0]+'1',res0[1]+s0[n]*(2**n)])
    if (res1[0]+'1').ljust(l,'0') <= Kstr:
        tmp1.append([res1[0]+'1',res1[1]+s0[n]*(2**n)])
    tmp1.sort(key=lambda x:x[0])
    tmp1.sort(key=lambda x:x[1],reverse=True)
    res1 = tmp1[0]
    res0 = nextres0

    n-=1

res0 = int('0b'+res0[0],0)
res1 = int('0b'+res1[0],0)

ans0=sum([res0^a for a in A])
ans1=sum([res1^a for a in A])

print(max(ans0,ans1))


Measured memory_bytes: 76384
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

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

	auto x1=in(),y1=in(),x2=in(),y2=in();
	double dx = x2-x1,dy = y2-y1;
	double norm = hypot(dx,dy);
	dx/=norm,dy/=norm;
	auto Q=in();
	REP(i,Q){
		int x3=in(),y3=in();
		double proj = dx*(x3-x1)+dy*(y3-y1);
		printf("%.10lf %.10lf\n",2*(proj*dx+x1)-x3,2*(proj*dy+y1)-y3);
	}

	return 0;
}



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

using namespace std;

const int N = (int)1e5 + 5;
int score[N];
int n, m;
vector<int> v[N];
bool vis[N];
void dfs(int root)
{
	vis[root] = true;
	for(int i=0;i<v[root].size();i++)
	{
		if(!vis[v[root][i]])
			dfs(v[root][i]);
		score[root] = max(score[root], 1+ score[v[root][i]]);
	}
}
		

int main()
{
	cin >> n >> m;
	for(int i=0;i<m;i++)
	{
		int x, y;
		cin >> x >> y;
		x--;
		y--;
		v[x].push_back(y);
	}
	for(int i=0;i<n;i++)
		if(!vis[i])
			dfs(i);
	int ans = 0;
	for(int i=0;i<n;i++)
		ans = max(ans, score[i]);
	cout << ans << "\n";
	return 0;
}



Measured memory_bytes: 8192