akhauriyash/Code-Regression huggingface dataset:
import math
A,B,H,M = map(int,input().split())

angle = min((30*H + 0.5*M) - 6*M, 360-((30*H + 0.5*M) - 6*M))
angle1 = math.floor(angle * 10 **2) / (10 **2)
ang_rad = math.radians(angle1)

cos = math.cos(ang_rad)
x = math.sqrt(A**2 + B**2 - 2*A*B*cos)

print(x)

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

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String[] s = sc.nextLine().split("");
		String[] t = sc.nextLine().split("");

		Arrays.sort(s);
		Arrays.sort(t, (o1, o2) -> {return o2.compareTo(o1);});

		String sAsc = String.join("", s);
		String tDesc = String.join("", t);

		if (sAsc.compareTo(tDesc) < 0) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
		sc.close();
	}
}

Measured memory_bytes: 26964
#!/usr/bin/env ruby
require 'prime'

n = gets.chomp.to_i

counter = Array.new(n + 1, 0)

1.upto(n) do |i|
  1.upto(i) do |j|
    counter[i] += 1 if i % j == 0
  end
end

ans = 0
counter.each_with_index do |c_i, i|
  ans += 1 if i.odd? && c_i == 8
end

puts ans


Measured memory_bytes: 14464
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <unordered_map>
#include <cmath>
#include <utility> // pair make_pair
#include <algorithm>
#include <functional>
#include <iomanip>
#include <climits> // LLONG_MAX, LLONG_MIN, INT_MIN, INT_MAX
#include <assert.h>

#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,63,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define ll long long
//#define int ll
#define INF INT_MAX/10

using namespace std;
using Pi = pair<int, int>;
using Graph = vector<vector<int> >;
using WeightGraph = vector<vector<Pi> >;

int main() {
  int N; cin >> N;
  int ans = 0;
  for (int i = 1; i <= N; i++) {
    string S = to_string(i);
    if (S.size() % 2 == 1) {
      ans++;
    }
  }
  cout << ans << endl;
}


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

const int M=2e5+5;

int uf[M],sz[M];
void init(int n)
{
	for(int i=1;i<=n;i++)
		uf[i]=i,sz[i]=1;
}
int find(int x)
{
	return x==uf[x]?x:uf[x]=find(uf[x]);
}
void merge(int a,int b)
{
	int fa=find(a),fb=find(b);
	if(fa==fb) return;
	sz[fa]+=sz[fb];
	uf[fb]=fa;
}

int main()
{
	int n,m; scanf("%d%d",&n,&m);
	init(n);
	int a,b;
	for(int i=0;i<m;i++)
	{
		scanf("%d%d",&a,&b);
		merge(a,b);
	}
	int mx=0;
	for(int i=1;i<=n;i++)
		mx=max(mx,sz[find(i)]);
	printf("%d\n",mx);
	return 0;
}

Measured memory_bytes: 5600
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define int long long
#define ar array<int,2>
#define inf 1000000000000000000 
int mod=1e9+7;
int min(int a,int b){return (a<b)?a:b;}
int max(int a,int b){return (a>b)?a:b;}
int fp(int a,int b){if(b==0) return 1;int x=fp(a,b/2);x=(x*x)%mod;if(b&1) x=(x*a)%mod;return x;}


const int N=2e5+5;



void solve()
{
    int n;
    cin>>n;
    set<array<int,2>> s;
    int a[n+1],b[n+1];
    map<int,int> mp1,mp2;
    for(int i=1;i<=n;i++)
    {
      cin>>a[i];
      mp1[a[i]]++;
    }
    for(int i=1;i<=n;i++)
    {
      cin>>b[i];
      mp2[b[i]]++;
    }

    for(auto &i:mp2)
    {
      s.insert({min(i.second,mp1[i.first]),i.first});
    }

//     for(auto i:s)
  //     cout<<i[0]<<" "<<i[1]<<endl;


    int c[n+1];
    for(int i=1;i<=n;i++)
    {
      auto it=s.rbegin();
      if((*it)[1]==a[i])
      {
        if(s.size()==1)
        {
          cout<<"No";
          return ;
        }


        it++;
      }

      auto ar1=(*it);
//      cout<<ar1[0]<<":"<<ar1[1]<<endl;
      s.erase(*it);


      int f1=mp1[a[i]];
      int f2=mp2[a[i]];
      if(f2>0){
      s.erase({min(f1,f2),a[i]});
      mp1[a[i]]--;
      s.insert({min(f1-1,f2),a[i]});
      }
      

      c[i]=ar1[1];
      //cout<<c[i]<<endl;

      mp2[c[i]]--;
      if(mp2[c[i]]>0)
      s.insert({min(mp2[c[i]],mp1[c[i]]),c[i]});

    }


    for(int i=1;i<=n;i++)
    {
      if(a[i]==c[i])
      {
        cout<<"No\n";
        return;
      }
       // cout<<c[i]<<" ";
    }

    cout<<"Yes\n";
    for(int i=1;i<=n;i++)
      cout<<c[i]<<" ";

}

signed main() {
 ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 
 srand(time(0));
 int t=1;
 //cin>>t;
 for(int i=1;i<=t;i++)
 {
   solve();
 }


}

Measured memory_bytes: 45712
H,W=map(int,input().split())
C=[]
A=[]
for i in range(10):
    C.append(list(map(int,input().split())))
for i in range(H):
    A.append(list(map(int,input().split())))
# WF
for i in range(10):
    for j in range(10):
        for k in range(10):
            C[j][k]=min(C[j][k], C[j][i]+C[i][k])
print(sum(sum(C[i][1] for i in AA if i >= 0) for AA in A))

Measured memory_bytes: 3316
def examA():
    K = I()
    A, B = LI()
    for i in range(A,B+1):
        if i%K==0:
            print("OK")
            return
    print("NG")
    return

def examB():
    X = I()
    now = 100
    ans = 0
    while(now<X):
        ans += 1
        now += now//100
    print(ans)
    return

def examC():
    N, M, Q = LI()

    ans = 0
    print(ans)
    return

def examD():
    A, B, N = LI()
    if N>=B-1:
        ans = (A*(B-1))//B
    else:
        ans = (A*N)//B
    print(ans)
    return

def examE():
    N, M = LI()
    ans = []
    if N%2==1:
        for i in range(N // 2):
            ans.append((i + 1, N - i))
    else:
        flag = False
        for i in range(N // 2):
            if N-i-(i+1)<=N//2:
                flag = True
            if flag:
                ans.append((i+1,N-i-1))
            else:
                ans.append((i + 1, N - i))
    #print(ans)
    for v in ans[:M]:
        print(" ".join(map(str,v)))
    return

def examF():
    N = I()
    A = LI()
    V = [[]for _ in range(N)]
    for _ in range(N-1):
        u, v = LI()
        u -= 1; v -= 1
        V[u].append(v)
        V[v].append(u)
    dp = [-1]*N
    dp[0] = 1
    LIS = deque()
    LIS.append(A[0])
    def dfs(s):
        #print(LIS)
        for i in V[s]:
            if dp[i]!=-1:
                continue
            flag = []
            if A[i] > LIS[-1]:
                LIS.append(A[i])
                flag = False
            else:
                flag = [bisect.bisect_left(LIS, A[i]),LIS[bisect.bisect_left(LIS, A[i])]]
                LIS[flag[0]] = A[i]
            dp[i] = len(LIS)
            dfs(i)
            #print(flag)
            if not flag:
                LIS.pop()
            else:
                LIS[flag[0]] = flag[1]
        return
    dfs(0)
    ans = dp
    for v in ans:
        print(v)
    return

import sys,bisect,itertools,heapq,math,random
from copy import deepcopy
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
def I(): return int(readline())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = 10**(-12)
alphabet = [chr(ord('a') + i) for i in range(26)]

sys.setrecursionlimit(10**7)

if __name__ == '__main__':
    examF()

"""
142
12 9 1445 0 1
asd dfg hj o o
aidn
"""

Measured memory_bytes: 383484
A = list(map(int, input().split()))
A.sort()

ans = A[2] - A[1]

if (A[1] - A[0]) % 2 == 0:
  print(ans + (A[1] - A[0]) // 2)
else:
  print(ans + (A[1] - A[0] + 1) // 2 + 1)



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

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()



int main() {
    ll a, b;
    cin >> a >> b;
    ll ans = 0;
    if (a == b) {
        cout << a << endl;
        exit(0);
    }
    if (a + 1 == b) {
        cout << (a ^ b) << endl;
        exit(0);
    }
    if (a % 2 == 1) {
        ans ^= a;
        a++;
    }
    if (b % 2 == 0) {
        ans ^= b;
        b--;
    }
    if ((b - a + 1) % 4) {
        ans ^= 1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//using
using intl = long long;
using itnl = long long;//typo用
using uintl = unsigned long long;
using itn = int;//typo用
using ld = long double;
using namespace std;

//関数マクロ
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define rrep(i, n) for(intl i = (intl)(n) - 1; i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define rrepi(i, a, b) for(intl i = (intl)(a) - 1; i >= (intl)(b); i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,1,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define alength(a) (sizeof(a) / sizeof(a[0]))
#define debug(x) cout << #x << ":" << x << endl

//定数マクロ
#define pb push_back
#define mp make_pair
#define pii pair<intl,intl>

//定数
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld EPS = 1.0e-14;//-9
const ld PI = acos(-1);

//テンプレート関数
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; }
//intl gcd(intl a, intl b){ if(!b)return a; return gcd(b, a % b); } //c++17からある
//intl lcm(intl a,intl b){ return a / gcd(a, b) * b; } //c++17からある

//自作テンプレート関数
void fp(bool f){cout << (f ? "Yes" : "No") << endl;}//Yes,Noの出力を楽にするよう
void fp(bool f, string s, string t){cout << (f ? s : t) << endl;}//上の関数のYes,Noを任意の文字列でできるようにしたもの
intl fact(intl k){ intl a = 1; for(int i = 2; i <= k; i++){ a *= i; } return a; }//k!を求める関数,O(N)
intl digit10(intl a){ intl b = 0; do{ a /= 10; b++; }while(a); return b; }//aを10進数で表したときの桁数を求める関数,O(logN)



signed main(){
    cout << fixed << setprecision(10);
    intl n;
    cin >> n;
    intl a[n];
    rep(i,n)cin >> a[i];
    intl ans = 0;
    intl b[n + 1];
    m0(b);
    rrepi(i, n, 1){
        b[i] = b[i + 1] + a[i];
    }
    //rep(i,n)cout << b[i] << endl;
    rep(i,n){
        ans += (a[i] * ((b[i + 1] ) % MOD)) % MOD;
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}


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

int main(void){
	string str;
	while(cin >> str){
		if(str[0]=='o' && str[1]=='o' && str[2]=='o')printf("o\n");
		else if(str[3]=='o' && str[4]=='o' && str[5]=='o')printf("o\n");
		else if(str[6]=='o' && str[7]=='o' && str[8]=='o')printf("o\n");
		else if(str[0]=='o' && str[3]=='o' && str[6]=='o')printf("o\n");
		else if(str[1]=='o' && str[4]=='o' && str[7]=='o')printf("o\n");
		else if(str[2]=='o' && str[5]=='o' && str[8]=='o')printf("o\n");
		else if(str[0]=='o' && str[4]=='o' && str[8]=='o')printf("o\n");
		else if(str[2]=='o' && str[4]=='o' && str[6]=='o')printf("o\n");
		else if(str[0]=='x' && str[1]=='x' && str[2]=='x')printf("x\n");
		else if(str[3]=='x' && str[4]=='x' && str[5]=='x')printf("x\n");
		else if(str[6]=='x' && str[7]=='x' && str[8]=='x')printf("x\n");
		else if(str[0]=='x' && str[3]=='x' && str[6]=='x')printf("x\n");
		else if(str[1]=='x' && str[4]=='x' && str[7]=='x')printf("x\n");
		else if(str[2]=='x' && str[5]=='x' && str[8]=='x')printf("x\n");
		else if(str[0]=='x' && str[4]=='x' && str[8]=='x')printf("x\n");
		else if(str[2]=='x' && str[4]=='x' && str[6]=='x')printf("x\n");
		else printf("d\n");
	}
    return 0;
}

Measured memory_bytes: 0
N = int(input())
v = list(map(int, input().split()))
from collections import Counter
ai = v[::2]
bi = v[1::2]
an = Counter(ai).most_common(2)
bn = Counter(bi).most_common(2)

if(an[0][0] == bn[0][0]):
    if(len(an)==1):
        print(int(N/2))
    else:
        print(N - an[0][1] - max(an[1][1], bn[1][1]))
else:
    print(N - an[0][1] - bn[0][1])

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

int main () {

    int N;
    cin >> N;

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

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

        bool seen = true;

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

            if (H[j] > H[i]) {
                seen = false;
            }
        }
        if (seen) {
            ans++;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
int main(){
       int n,a,c1=0,c2=0,c4=0;
       scanf("%d",&n);
       for(int i=0;i<n;i++){
              scanf("%d",&a);
              if(a%4==0) c4++;
              else if(a%2==0) c2++;
              else c1++;
       }
       if(c1==0) printf("Yes");
       else{
              if(c2==0&&c4>=c1-1)printf("Yes");
              else if(c2!=0&&c4>=c1) printf("Yes");
              else printf("No");
       }
       return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  cin>>a>>b;
  int ans=-1;
  for(int i=1;i<=1009;i++){
    int x,y;
    x=i*8;
    y=i*10;
    x/=100;
    y/=100;
    if(x==a&&b==y){
      ans=i;
      break;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
n,k=map(int,input().split())
r,s,p=map(int,input().split())
t=input()
point=0
l=[]
point_list=[r,s,p]
kind=['r','s','p','r']
for i in range(n):
  for j in range(len(kind)-1):
    if t[i]==kind[j]:
      if i-k>=0 and t[i]==kind[l[i-k]+1]:
        if i+k<n and t[i+k]==kind[j+1]:
          if j==2:j=-1
          l.append(j+1)
        else:
          l.append(j)
      else:
        point+=point_list[j-1]
        if j==0:j=3
        l.append(j-1)
      break
print(point)

Measured memory_bytes: 4212
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <queue>
#include <vector>
#include <cmath>
using namespace std;

#define LL long long

const int MAXN = 10000000 + 5;
const LL MOD = 1000000000 + 7;


int c[MAXN], a[MAXN];


bool divide(int m){
    bool pairwiseCoprime = true;
    for (int i = 2; i * i <= m; i ++){
        if (m % i == 0){
            if (c[i] > 0){
                pairwiseCoprime = false;
            }
            while (m % i == 0){
                c[i] ++;
                m /= i;
            }
        }

    }
    if (m > 1){
        if (c[m] > 0){
            pairwiseCoprime = false;
        }
        c[m] ++;
    }
    return pairwiseCoprime;
}


int gcd(int a,int b)
{
     return b==0?a:gcd(b,a%b);
}

int main()
{
    int N, maxa = 0;
    memset(c, 0, sizeof(c));
    cin >> N;
    bool pairwiseCoprime = true;
    for (int i = 0; i < N ; i ++){
        cin >> a[i];
        maxa = max(a[i], maxa);
        if (pairwiseCoprime){
            pairwiseCoprime = divide(a[i]);
        }
    }

    if (pairwiseCoprime){
        cout << "pairwise coprime";
    }
    else{
        int factor = gcd (a[0], a[1]);
        for (int i = 2; i < N ; i ++){
            factor = gcd (factor, a[i]);
            if (factor <= 1){
                break;
            }
        }
        if (factor <= 1){
            cout << "setwise  coprime";
        }
        else{
            cout <<  "not coprime";
        }
    }
    system("pause");
    return 0;
}

Measured memory_bytes: 46584
k= int(input())
a = 7 % k
a_list = [a]
for _ in range(k):
    an = a_list[-1]
    a_list.append((10*an+7)%k)
for ind, num in enumerate(a_list):
    if num == 0:
        print(ind+1)
        break
    if ind == k-1:
        print(-1)

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

int main(){
    std::string s;
    std::cin >> s;

    int hug_num = 0;
//    cout << s.length() << endl;
    for ( int i = 0; i < s.length() / 2; i++ ) {
//        cout << s.substr(i, 1) << endl;
//        cout << s.substr(s.length() - i - 1, 1) << endl;
        if ( s.substr(i, 1) != s.substr(s.length() - i - 1, 1) ) {
            hug_num++;
        }
    }

    cout << hug_num << endl;

    return 0;
}

Measured memory_bytes: 256
#include <string>
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <vector>
#include <cmath>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;

struct UnionFind {
  vector<int> d;
  UnionFind(int n=0): d(n,-1) {}
  int find(int x) {
    if (d[x] < 0) return x;
    return d[x] = find(d[x]);
  }
  bool unite(int x, int y) {
    x = find(x); y = find(y);
    if (x == y) return false;
    if (d[x] > d[y]) swap(x,y);
    d[x] += d[y];
    d[y] = x;
    return true;
  }
  bool same(int x, int y) { return find(x) == find(y);}
  int size(int x) { return -d[find(x)];}
};

int main()
{
  int n, m;
  cin >> n >> m;
  UnionFind uf(n); 
  int max_size = 0;
  int max_index = 0;
  rep(i,m){
    int a, b;
    cin >> a >> b;
    a--; b--;
    uf.unite(a, b);
    if(max_size <= uf.size(a))
      max_size = uf.size(a);  
      max_index = a;
  }
  int maked_load = 0;
  rep(i,n){
    // cout << max_size << " " << uf.size(i) << max_index << endl;
    if(max_size == n) break;
    if(uf.size(i) == max_size) continue;
    maked_load++;
    uf.unite(i,max_index);
    max_size = uf.size(i);
  }
  cout << maked_load << endl;
}

Measured memory_bytes: 3752
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <algorithm>
using namespace std;

#define Rep(i,l,r) for (int i = (l); i <= (r); ++ i)
#define RepD(i,r,l) for (int i = (r); i >= (l); -- i)
#define RepG(i,x) for (int i = hd[x]; i; i = e[i].nxt)

const int N = 2e5+5;
int n, mx = 0, mi = 1234567, cnt = 0;
int a[N];

int main () {
	scanf ("%d", &n);
	Rep(i,1,n) {
		scanf ("%d", &a[i]);
		mx = max (mx, a[i]); mi = min (mi, a[i]);
	}
	if (mx-mi>1) {puts ("No"); return 0;}
	if (mx==mi) {
		if (mx==n-1 || mx*2<=n) {puts ("Yes"); return 0;}
		puts ("No"); return 0;
	}
	Rep(i,1,n) if (a[i]==mi) ++ cnt;
	if (cnt<mx && mx<=cnt+(n-cnt)/2) {puts ("Yes"); return 0;}
	{puts ("No"); return 0;}
	return 0;
}


Measured memory_bytes: 640
(let* ((n (read))
       (lst (loop :repeat n :collect (cons (read) (read)))))
  (setf lst (sort lst #'< :key #'cdr))
  (let* ((time 0)
         (ans T))
    (map nil (lambda (a)
               (incf time (car a))
               (setf ans (and ans (<= time (cdr a)))))
         lst)
    (if ans (princ "Yes") (princ "No"))))

Measured memory_bytes: 63912
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <string>
#include <cstring>
#include <complex>
#include <ctime>
#include <cstdlib>

using namespace std;

inline int to_int(string s) {int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string to_str(T x) {ostringstream sout; sout << x; return sout.str();}

typedef long long ll;

struct point
{
	double x;
	double y;
	point()
	{
		x = 0.0;
		y = 0.0;
	}
	point(double a, double b)
	{
		x = a;
		y = b;
	}
};
//直線-線分の交差判定
//s
bool c_s_cross(point s, point t, point u, point v)
{
	double tc = (s.x - t.x)*(u.y - s.y) + (s.y - t.y)*(s.x - u.x);
	double td = (s.x - t.x)*(v.y - s.y) + (s.y - t.y)*(s.x - v.x);

	if(tc*td < 0)
	{
		return true;
	}
	else
	{
		return false;
	}
}

bool judge(point a, point b, point c, point d)
{
	if(c_s_cross(a, c, b, d) && c_s_cross(b, d, a, c))
	{
		return true;
	}
	else
	{
		return false;
	}
}

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

	while(~scanf("%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf",&a.x ,&a.y ,&b.x ,&b.y ,&c.x ,&c.y ,&d.x ,&d.y))
	{
		//printf("%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf",a.x ,a.y ,b.x ,b.y ,c.x ,c.y ,d.x ,d.y);
		cout << (judge(a, b, c, d)?"YES":"NO") << endl;
	}
}

Measured memory_bytes: 1224
# -*- coding: utf-8 -*-
"""
https://beta.atcoder.jp/contests/abc080/tasks/abc080_b

"""
import sys
from sys import stdin
input = stdin.readline


def is_harshad(N):
    result = False
    divisor = 0
    num = N
    while num:
        divisor += num % 10
        num //= 10
    if N % divisor == 0:
        result = True
    return result


def main(args):
    N = int(input())
    if is_harshad(N):
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main(sys.argv[1:])


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>

#include <cmath>
#include <cstdlib>
#include <climits>

//#include <stdio.h>
//#include <stdlib.h>


using namespace std;

#define debug false

int main(int argc, char *argv[]){

  int N;
  cin >> N;
  int a[N];
  for(int i = 0; i < N; i++){
    cin >> a[i];
  }
  int cnt = 0;
  while(true){
    for(int i = 0; i < N; i++){
      if(a[i]%2 == 0){
        a[i] /= 2;
      }else{
        goto END;
      }
    }
    cnt ++;
  }
  END :
  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#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(){
    string s;
    cin >> s;
    cout << s.substr(0, 3);
    return 0;
}


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

vector<vector<int>> G;
vector<bool> m0;
vector<bool> m1;
vector<bool> m2;
int S, T;

int main() {
    int N, M;
    cin >> N >> M;
    G.resize(N), m0.resize(N, 0), m1.resize(N, 0), m2.resize(N, 0);
    rep(i, M) {
        int u, v;
        cin >> u >> v;
        --u, --v;
        G[u].push_back(v);
    }
    cin >> S >> T;
    --S, --T;

    vector<vector<int>> dist(N, vector<int>(3, -1));
    dist[S][0] = 0;
    queue<pair<int, int>> q;
    q.push({S, 0});

    while (!q.empty()) {
        int v = q.front().first;
        int p = q.front().second;
        q.pop();
        for (auto nv : G[v]) {
            int np = (p + 1) % 3;
            if (dist[nv][np] == -1) {
                dist[nv][np] = dist[v][p] + 1;
                q.push({nv, np});
            }
        }
    }
    if (dist[T][0] == -1)
        cout << -1 << endl;
    else
        cout << dist[T][0] / 3 << endl;
}

Measured memory_bytes: 11264
#include <iostream>
#include <complex>
#include <vector>
#include <unordered_map> 
#include <algorithm>

/*
 * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2331&lang=jp
 * test of c++
 */


template <typename T>
std::vector<std::vector<T>> read_input() {
    std::string input_str;

    std::getline(std::cin, input_str);
    int arr_size = std::stoi(input_str);
    std::vector<std::vector<T>> input_vec(arr_size, std::vector<int>(2, 0));

    for (size_t i = 0; i < arr_size; i++) {
        std::getline(std::cin, input_str);
        std::istringstream iss(input_str);
        T begin, end;
        iss >> begin >> end;

        // this is for myself
        begin -= 1;
        end -= 1;
        input_vec.at(i).at(0) = begin;
        input_vec.at(i).at(1) = end;
    }
    return input_vec;
}


// bool verify(std::vector<std::vector<int>> input_vec, int ans) {
//     if (ans == 0) {
//         return true;
//     }
//     int count = 0;
//     for (int i = 0; i < input_vec.size(); i++) {
//         std::vector<int> person = input_vec.at(i);
//         if (person.at(0) <= ans && ans <= person.at(1)) {
//             count++;
//         }
//         if (count == ans) {
//             return true;
//         }
//     }
//     return false;
// }


// void search(std::vector<std::vector<int>> input_vec, int bottom, int top, int* ans) {
//     if (bottom >= top) {
//         if (*ans > bottom) {
//             return;
//         }
//         else {
//             if (verify(input_vec, bottom)) {
//                 *ans = bottom;
//             }
//             return;
//         }
//     }
//     int num = bottom + (top - bottom) / 2;
//     if (verify(input_vec, num)) {
//         *ans = num;
//         search(input_vec, num+1, top, ans);
//     }
//     else {
//         search(input_vec, num+1, top, ans);
//         search(input_vec, bottom, num-1, ans);
//     }
    // naive
    // int ans;
    // for (int num = 0; num <= size; num++) {
    //     if (verify(input_vec, num)) {
    //         ans = num;
    //     }
    // }
    // return ans;
// }


int main(int argc, char const *argv[]) {
    std::vector<std::vector<int>> input_vec = read_input<int>();
    // search(input_vec, 0, input_vec.size(), &ans);

    // counts[j] people can endure j+1 people.
    std::vector<int> counts(input_vec.size(), 0);
    for (int i = 0; i < input_vec.size(); i++) {
        std::vector<int> person = input_vec.at(i);
        for (int j = person.at(0); j <= person.at(1) && j <= counts.size(); j++) {
            counts.at(j-1) += 1;
        }
    }
    // for (int i = 0; i < counts.size(); i++) {
    //     std::cout << counts.at(i);
    // }
    // std::cout << std::endl;

    int ans = 0;
    for (int i = 0; i < counts.size(); i++) {
        if (counts.at(i) > i) {
            ans = i + 1;
        }
    }
    std::cout << ans << std::endl;
    return 0;
}



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

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

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;


//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}


int main(){
  string s;
  cin >> s;
  ll ans = 0;
  rep(i,s.size()) if(s[i] == '1') ans++;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
using namespace std;
int main()
{
    int a,b,c;
    while(scanf("%d",&a)!=EOF)
    {
         b=a/100;
         c=a%10;
         if(b==c)
         cout<<"Yes"<<endl;
         else
         cout<<"No"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <random>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <sstream>
#include <bitset>
#include <cassert>
#include <fstream>
#include <queue>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
	#define DBG(X) cout << #X << "=" << (X) << endl;
#else
	#define DBG(X)
#endif

using std::cin;
using std::cout;
using std::vector;
using std::string;
using std::pair;
using std::swap;
using std::sort;
using std::lower_bound;
using std::unique;

using int64 = long long int;
using pii   = pair<int, int>;
using pii64 = pair<int64, int64>;

const int NIL = -1;

void init_IO() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
}

const int MAX_N = (int)1e5 + 777;
int64 a[MAX_N], L;
int n;

void solve() {
	cin >> n >> L;

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

	int pos = 0;

	for(int i = 1; i < n - 1; ++i) {
		if(a[i] + a[i + 1] > a[pos] + a[pos + 1])
			pos = i;
	}

	if(a[pos] + a[pos + 1] < L) {
		cout << "Impossible\n";
		return;
	}

	vector<int> answ;

	int cut = pos + 1;

	for(int i = n - 1; i > cut; --i) {
		answ.push_back(i);
	}

	for(int i = 1; i < cut; ++i) {
		answ.push_back(i);
	}

	answ.push_back(cut);

	cout << "Possible\n";

	for(auto& pos: answ) {
		cout << pos << '\n';
	}
}

int main() {
	init_IO();
	solve();

	return 0;
}


Measured memory_bytes: 2168
n,p=gets.split.map(&:to_i)
a=gets.split.map(&:to_i)
c=Array.new(2) { 0 }
a.each do |e|
  c[e%2] += 1
end
def fact(n)
  if n == 0
    1
  else
    n * fact(n-1)
  end
end
def ncr(n, r)
  fact(n) / (fact(n-r) * fact(r))
end
count = 0
if p == 1
  count = 0
  (1..c[1]).step(2) do |r|
    count += ncr(c[1], r)
  end
  mul = 0
  (0..c[0]).each do |r|
    mul += ncr(c[0], r)
  end
  count *= mul
else
  count = 0
  (0..c[1]).step(2) do |r|
    count += ncr(c[1], r)
  end
  mul = 0
  (0..c[0]).each do |r|
    mul += ncr(c[0], r)
  end
  count *= mul
end
puts count


Measured memory_bytes: 1788
import java.util.Scanner;

public class Main {
       public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        while (true) {
            int height = input.nextInt();
            int width = input.nextInt();
            if(width == 0 || height == 0) break;
            for(int i = 0; i < height;i++){
                for(int j = 0; j < width; j++){
                    System.out.print("#");
                }
                System.out.println("");
            }
            System.out.println("");
        }
        //System.out.println("");
    }
}


Measured memory_bytes: 34496
#include<bits/stdc++.h>
 #include <ext/pb_ds/tree_policy.hpp>
 #include <ext/pb_ds/assoc_container.hpp>
 #include<chrono>
 using namespace std;
 using namespace std::chrono;      
 using namespace __gnu_pbds; 
 #define fastio     ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
 #define fi         first
 #define se         second
#define int         long long 
 #define pb         push_back
 #define emp        emplace_back
 #define vv(x)      vector<x>
 #define mp(x,y)    map<x,y>
 #define dq(x)      deque<x>
 #define pql(x)     priority_queue<x>
 #define pqs(x)     priority_queue<x,vv(x),greater<x> >
 #define mod        1000000007
 #define forf(i,a,b) for(int i=a;i<b;i++)
 #define it(x)      x::iterator
 #define ll         long long 
 #define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
 #define time__(d)  for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false); debug("%s time : %.4fs", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
 #define vii        vector<int>
 #define big        2e18
 #define sm         -1e9
 #define mkr        make_pair
 #define vpi        vector<pair<int,int> >
 #define pii        pair<int,int>
 #define rng        500005
 #define sz(x)      (int)x.size()
 #define rv(x)      reverse(x.begin(),x.end())
 #define out(x)     cout<<x.fi<<" "<<x.se<<endl;

#define ordered_set tree<pii, null_type,less<pii>, rb_tree_tag,tree_order_statistics_node_update> 
  
void pr_init()
{
   
    #ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
   
    #endif
}



void solve()
{
 
 int x;
 cin>>x;
 int an = (x/500)*1000 + ((x%500)/5)*5;
 cout<<an<<endl;
 
}

int32_t main()
{
  //pr_init();
  //fastio;
  
  auto start = high_resolution_clock::now(); 
 
  solve();
  auto stop = high_resolution_clock::now();
  auto duration = duration_cast<microseconds>(stop - start); 
  
    // cout << "Time taken by function: "
    //      << duration.count() << " microseconds" << endl; 

 }


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

using namespace std;

#ifdef LOCAL_DEFINE
  #include "../../library/DEBUG.hpp"
#else
  #define debug(...) 0
#endif

int main(void) {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int a;
  cin >> a;
  cout << a + a * a + a * a * a << '\n';
  return 0;
}

Measured memory_bytes: 3536
#include <stdio.h>
#define N 100

int main(){
  int i, j, c=0, n, A[N], key=0;

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

    for(i = 0; i < n-1; i++){
      for(j = 0; j < n-1; j++){
	if(A[j] > A[j+1]) {
	  key = A[j];
	  A[j] = A[j+1];
	  A[j+1] = key;
	  c++;
	}
      }
    }
    
  
    
  for ( i = 0; i < n; i++ ){
    if ( i > 0 ) printf(" ");
    printf("%d", A[i]);
  }
  printf("\n");
  printf("%d\n",c);
    
  return 0;
}

Measured memory_bytes: 604
import java.util.*;
 
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int L = sc.nextInt();
		double ans = (L/3.0)*(L/3.0)*(L/3.0);
		System.out.println(String.format("%.7f", ans));
    }
}


Measured memory_bytes: 35856
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define ff first
#define ss second
#define ll long long
#define vi vector<int>
#define vii vector<vi>
#define vs vector<string>
#define vss vector<vs>
#define pii pair<int, int>
#define all(x) x.begin(), x.end()
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define repr(i, a, n) for (int i = (n); i >= (a); --i)
using namespace std;
const int INF(1 << 30);
const ll LLINF(1LL << 55LL);
const int pi = 3.1415926536;
const int MOD = 1000000007;
const int MAX = 510000;

void Main() {
  int n;
  cin >> n;
  if(n==1){
    cout<<1<<endl;
    return;
  }
  int ans, max = -INF;
  rep(i, 1, n + 1) {
    if (i % 2 != 0) continue;
    int cnt = 0;
    int calc = i;
    while (calc % 2 == 0) {
      calc /= 2;
      cnt++;
    }
    if (cnt > max) {
      max = cnt;
      ans = i;
    }
  }
  cout << ans << endl;
}

int main() {
  std::cin.tie(nullptr);                  // 標準入出力高速化
  std::ios_base::sync_with_stdio(false);  // SとS++の入出力出力を非同期
  std::cout << std::fixed << std::setprecision(15);  // 小数を10進数表示
  Main();
}

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

#define ll long long
#define endl "\n";
#define mod 1000000007
#define pii pair<int,int>
#define vii vector<pii>
#define mp make_pair
#define all(a) a.begin(), a.end()
#define mk(arr,n,type) type *arr=new type[n];

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

char reVal(int num)
{
    return (char) (num + 'a');
}

void strev(char *str)
{
    int len = strlen(str);
    int i;
    for (i = 0; i < len / 2; i++)
    {
        char temp = str[i];
        str[i] = str[len - i - 1];
        str[len - i - 1] = temp;
    }
}

char* fromDeci(char res[], ll base, ll inputNum, int digits)
{
    int index = 0;

    while (inputNum > 0)
    {
        //cout << inputNum % base << endl;
        res[index++] = reVal(inputNum % base);
        inputNum /= base;
    }
    while (index < digits) {
        res[index++] = 'a';
    }

    res[index] = '\0';

    strev(res);

    return res;
}

int main() {
    fastio();
    ll n;
    cin >> n;

    int digits = 1;
    ll basenumber = 26;
    while (basenumber < n) {
        ll newnumber = basenumber * 26 + 26;
        digits++;
        if (newnumber < n) basenumber = newnumber;
        else break;
    }
    if (digits == 1) basenumber = 0;

    char res[100];
    ll rem = n - basenumber - 1;

    //cout << basenumber << ", " << rem << ", " << digits << endl;
    printf("%s\n", fromDeci(res, 26, rem, digits));
    return 0;
}


Measured memory_bytes: 3584
char out[1<<20];outsz;
char ffs[]="0101110101011101110111010101110101011101010111011101110101011101110111010101110111011101010111010101110101011101110111010101110101011101010111011101110101011101010111010101110111011101010111011101110101011101110111010101110101011101010111011101110101011101110111010101110111011101010111010101110101011101110111010101110111011101010111011101110101011101010111010101110111011101010111010101110101011101110111010101110101011101010111011101110101011101110111010101110111011101010111010101110101011101110111010101110101011101010111011101110101011101010111010101110111011101010111011101110101011101110111010101110101011101010111011101110101011101010111010101110111011101010111010101110101011101110111010101110111011101010111011101110101011101010111010101110111011101010111011101110101011101110111010101110101011101010111011101110101011101110111010101110111011101010111010101110101011101110111010101110101011101010111011101110101011101010111010101110111011101010111011101110101011101110111010101110101011101010111011101110101011101";
char in[9];
main(){
	read(0,in,5);
	int N,M;
	if(in[1]==' ')
	{
		N=in[0]-'0';
		if(in[3]=='\n')
		{
			M=in[2]-'0';
		}
		else
		{
			M=10;
		}
	}
	else
	{
		N=10;
		if(in[4]=='\n')
		{
			M=in[3]-'0';
		}
		else
		{
			M=10;
		}
	}
	for(int i=1;i<1<<N;i++)
	{
		for(int j=1;j<1<<M;j++)
		{
			out[outsz++]=ffs[i|j];
		}
		out[outsz++]='\n';
	}
	write(1,out,outsz);
}


Measured memory_bytes: 2176
N,K = [int(x) for x in input().split()]

result = 0

if (K%2) == 1:
    kouho = N//K
    result+=kouho*kouho*kouho

else:
    kouho1 = N//K
    kouho2 = N//(K/2) - kouho1
    result+=kouho1*kouho1*kouho1
    result+=kouho2*kouho2*kouho2

print(int(result))



Measured memory_bytes: 2940
n = gets.to_i
g = {}
(1..n).map {|i| g[i] = []}
depth = {1 => 0}
gets.split.map(&:to_i).each_with_index do |x, i|
	g[x] << i+2
	depth[i+2] = depth[x] + 1
end

bfs_order = []
queue = [1]
idx = 0
until queue.empty?
	u = queue.shift
	bfs_order << u
	g[u].each {|v| queue << v}
end

def compute_euler_tour_index(graph, u)
	idx = 0
	et = {u => [0]}
	stack = [[u, 0]]
	loop do
		u, i = stack[-1]
		if i >= graph[u].size
			stack.pop
			break if stack.empty?
			et[stack[-1][0]] << (idx += 1)
			stack[-1][1] += 1
		else
			v = graph[u][i]
			stack << [graph[u][i], 0]
			et[v] = [idx += 1]
		end

	end
	return et
end

et = compute_euler_tour_index(g, 1)

ary = []
et.each do |k, is|
	is.each do |i|
		ary[i] = depth[k]
	end
end

class SegmentTree
	def initialize(arr, l = 0, r = arr.size - 1)
		@l = l
		@r = r
		if l == r
			@min = arr[l]
		else
			c = (l + r) / 2
			@left_child = self.class.new(arr, l, c)
			@right_child = self.class.new(arr, c+1, r)
			lm = @left_child.min
			rm = @right_child.min
			@min = (lm < rm ? lm : rm)
		end
	end

	def query(l, r)
		return @min if l == @l && r == @r
		if r <= @left_child.r
			return @left_child.query(l, r)
		elsif @right_child.l <= l
			return @right_child.query(l, r)
		else
			lm = @left_child.query(l, @left_child.r)
			rm = @right_child.query(@right_child.l, r)
			return lm < rm ? lm : rm
		end
	end

	attr_reader :min, :l, :r
end

tree = SegmentTree.new(ary)

total_dist = 0
bfs_order.each_cons(2) do |u, v|
	is = [et[u][0], et[u][-1], et[v][0], et[v][-1]].sort
	lca_depth = tree.query(is[0], is[-1])
	total_dist += (ary[et[u][0]] + ary[et[v][0]] - lca_depth * 2)
end
p total_dist

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

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

#define INF             2e9
#define INF_LL          1LL<<60
#define ll              long long
#define Ceil(x, n)      (((((x))+((n)-1))/n))
#define CeilN(x, n)     (((((x))+((n)-1))/n)*n)
#define FloorN(x, n)    ((x)-(x)%(n))
#define ALL(x)          (x).begin(),(x).end()
typedef pair<ll, ll>    P;

int main() {
    string s;
    cin >> s;
    ll black_num = 0;
    ll ans = 0;

    REP(i, s.size()) {
        if(s[i] == 'W') {
            ans += black_num;
        } else {
            black_num++;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        try (Scanner sc = new Scanner(System.in)) {
            int w = sc.nextInt();
            int n = sc.nextInt();
            int[] values = new int[w];
            for (int i = 0; i < values.length; i++) {
            values[i] = i + 1;
            }
            for (int i = 0; i < n; i++) {
            String str = sc.next();
            String[] ab = str.split(",");
            int a = Integer.parseInt(ab[0]) - 1;
            int b = Integer.parseInt(ab[1]) - 1;

            int tmp = values[a];
            values[a] = values[b];
            values[b] = tmp;
            }
            for(int i = 0; i < values.length; i++){
                System.out.println(values[i]);
            }
    }
    }
}


Measured memory_bytes: 26036
# ABC132D - Blue and Red Balls
def main():
    N, K = map(int, input().split())
    MOD = 10 ** 9 + 7
    x = N - K + 1
    ans = [x]
    for i in range(2, K + 1):
        x = x * (N - K + 2 - i) * (K - i + 1) // (i * (i - 1))
        ans.append(x % MOD)
    print("\n".join(map(str, ans)))


if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
# import math
# import statistics
# import itertools
a=int(input())
#b,c=int(input()),int(input())
# c=[]
# for i in a:
#     c.append(int(i))
# e1,e2,e3,e4 = map(int,input().split())
#f = list(map(int,input().split()))
# g = [input() for _ in range(a)]

print(a+a**2+a**3)

Measured memory_bytes: 9052
/*
ID: anonymo14
TASK: wormhole
LANG: C++                 
*/
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

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

#define MOD 1000000007

void solve(int test_case) {//222
	int a,b,c,k;
	cin>>a>>b>>c>>k;
	if(a>=b&&a>=c)a<<=k;
	else if(b>=c&&b>=a)b<<=k;
	else c<<=k;
	cout<<a+b+c;
}

int main() {
	
	////// FILE BASED IO////
	//freopen("wormhole.in", "r", stdin);
	//freopen("wormhole.out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
	return 0;
}	


Measured memory_bytes: 3584
/*
                       _oo0oo_
                      o8888888o
                      88" . "88
                      (| -_- |)
                      0\  =  /0
                    ___/`---'\___
                  .' \\|     |// '.
                 / \\|||  :  |||// \
                / _||||| -:- |||||- \
               |   | \\\  -  /// |   |
               | \_|  ''\---/''  |_/ |
               \  .-\__  '-'  ___/-. /
             ___'. .'  /--.--\  `. .'___
          ."" '<  `.___\_<|>_/___.' >' "".
         | | :  `- \`.;`\ _ /`;.`/ - ` : | |
         \  \ `_.   \_ __\ /__ _/   .-` /  /
     =====`-.____`.___ \_____/___.-`___.-'=====
                       `=---='
 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
  Vikash Kumar @ Codechef/codeforces 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/   
#include<bits/stdc++.h>
 
#define ll                    long long int
#define ll_MAX                LLONG_MAX
#define ll_MIN                LLONG_MIN
#define pi                    3.14159265358979323846
#define count_1(n)            __builtin_popcountll(n)
#define MOD                   1000000007
#define MAX                   1e9
#define MIN                   -1e9
#define itoc(c)               ((char)(((int)'0')+c))
#define mid(s,e)              (s+(e-s)/2)
const int MX=10010896;
const int lmt=3164;
const int N=10000001;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
ll extgcd(ll a,ll b,ll& x,ll& y){if(b==0){x=1;y=0;return a;}else{int g=extgcd(b,a%b,y,x);y-=a/b*x;return g;}}
ll modpow(ll a,ll b) {ll res=1;a%=MOD;for(;b;b>>=1){if(b&1)res=res*a%MOD;a=a*a%MOD;}return res;}

bool dp[100005];

inline void solve(){
    /*<logic>*/
    int n,k;cin>>n>>k;
    int arr[n];
    for(int i=0;i<n;i++)
      cin>>arr[i];
    memset(dp,false,sizeof(dp));
    for(int stone=0;stone<=k;stone++){
      for(int a:arr){
        if(stone>=a && !dp[stone-a]){
          dp[stone]=true;
          break;
        }
      }
    }
    if(dp[k])
      cout<<"First"<<endl;
    else
      cout<<"Second"<<endl;
    /*</logic>*/
   
}

int main()
{
	cout<<fixed<<setprecision(12);
	//freopen("input.txt", "r", stdin);
	fastio;ll  t=1,tc=1;
	//cin>>t;
	while(t--){solve();}return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
using namespace std;

int main(void) {

    string s;
    cin >> s;
    int ans = 0;
    for(int i=1; i<s.size(); i++){
        if( s[i-1] != s[i] ) ans++;
    }
    cout << ans << endl;

    return 0;
}


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

int main(){
//srandom((unsigned long)time(NULL));
long long n,k,q;
cin>>n>>k>>q;
vector<long long> p(n);
for(long long i=0;i<n;i++)p[i]=k-q;
for(long long i=0;i<q;i++){
    long long a;
    cin>>a;
    p[a-1]++;
}
for(long long i=0;i<n;i++){
    if(p[i]>0){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}

return 0;
}

Measured memory_bytes: 1408
import math


def main():
    n = int(input())
    l = [i for i in range(1, n + 1)]

    def gen(l):
        for i in l:
            for j in l:
                for k in l:
                    yield math.gcd(i, math.gcd(j, k))

    return sum(gen(l))


if __name__ == '__main__':
    print(main())


Measured memory_bytes: 9180
T, B = 0, 1
n = gets.to_i
deck = n.times.map{gets.split.map(&:to_i)}

dp = Array.new(n){Array.new(n){1<<32}}
n.times do |i| dp[i][i] = 0 end
(1 ... n).each do |d|
  (0 ... n - d).each do |i|
    (i ... i + d).each do |j|
      dp[i][i + d] = [dp[i][i + d], dp[i][j] + dp[j + 1][i + d] + deck[i][T] * deck[j][B] * deck[j + 1][T] * deck[i + d][B]].min
    end
  end
end
p dp[0][n - 1]

Measured memory_bytes: 6124
#include <stdio.h>
int check(){
	//全て偶数かどうかを調べる
	
}
int main(void){
	int n;
	scanf("%d",&n);
	int i;
	int a[n];
	for(i=0;i<n;i++)scanf("%d",&a[i]);
	int ans = 0;
	int check(){
	//全て偶数かどうかを調べる
		for(i=0;i<n;i++){
			if(a[i]%2!=0){
				return -1;
			}
		}
		return 1;
	}
	while(check()==1){
		for(i=0;i<n;i++){
			a[i]/=2;	
		}
		ans ++;
	}
	printf("%d",ans);
	return 0;
}

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

int main(){
    using namespace std;
    unsigned long N, K;
    cin >> N >> K;
    vector<long> A(N), B;
    for(auto& i : A)cin >> i;
    sort(A.begin(), A.end());
    copy(A.rbegin(), A.rend(), back_inserter(B));
    const auto& cnt = [&N, &A, &B](long X) -> unsigned long{
        unsigned long ans{0};
        for(const auto& i : A){
            const vector<long>& t = (i > 0 ? A : B);
            ans += partition_point(begin(t), end(t), [&i, &X](auto x){return i * x <= X;}) - begin(t) - (i * i <= X ? 1 : 0);
        }
        return ans;
    };
    long R{-2000000000000000000}, L{2000000000000000000};
    while(R + 1 < L){
        auto M = (R + L) / 2;
        (cnt(M) >= K * 2 ? L : R) = M;
    }
    cout << L << endl;
    return 0;
}

Measured memory_bytes: 3956
# C - Reconciled?
def main():
    from math import factorial

    n, m = map(int, input().split())
    p = 10**9+7

    if abs(n-m) < 2:
        if n == m:
            print(2*factorial(n)*factorial(m)%p)
        else:
            print(factorial(n)*factorial(m)%p)
    else:
        print(0)

if __name__ ==  "__main__":
    main()

Measured memory_bytes: 10880
n, a = map(int, input().split())
x = list(map(int, input().split()))

x.sort()
x = [i - a for i in x]
# print(x)
D = {0 : 1}
for i in x:
    for j, k in list(D.items()):
        D[i+j] = D.get(i+j, 0) + k

    # print(D)
print(D[0] - 1)


Measured memory_bytes: 3188
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define tll tuple<ll, ll, ll>
#define all(c) c.begin(),c.end()

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
 
const ll inf = 1000000001;
const ll INF = 1e18;
const ll MOD = 1000000007;

char albt[26] = {'a','b','c','d','e','f','g','h','i','j','k','l',
                 'm','n','o','p','q','r','s','t','u','v','w','x',
                 'y','z'};

//vector<ll> g[202020];
//fill(score, score+202020, 0);
//vector<ll> v;

int main(){
  ll a, b;
  cin >> a >> b;
  
  set<ll> s;
  ll c = 2;
  while(c*c<=a){
    while (a%c == 0){
      if (b%c == 0) s.insert(c);
      a = a/c;
      //cout << a << " " << c << endl;
    }
    if (a == 1) break;
    c += 1;
  }
  
  if (a != 1){
    if (b%a == 0) s.insert(a);
  }
  
  //for (int i=0;i<koyaku.size();i++) cout << koyaku[i] << " ";
  //cout << endl;
  cout << s.size() + 1 << endl;
}

Measured memory_bytes: 256