akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
//#include <iomanip>
//#include <string>
//#include <vector>
#include <algorithm>
//#include <utility>
#include <set>
//#include <map>
//#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
//using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;
//#define all(v) v.begin(),v.end()
//ll mod = 1000000007 ;
//long double pie = acos(-1) ;
//ll INF = 100000000 ;

//void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void mysort(vector<long long> &a){sort(a.begin(),a.end()) ;}
//void myrev(vector<long long> &a){reverse(a.begin(),a.end()) ;}
//void fix_cout(){cout << fixed << setprecision(20) ;}

int main(){
	ll a,b,c,d,e,f ;
	cin >> a >> b >> c >> d >> e >> f ;
	set<ll> w,s ;
	for(int i=0;i<=30;i++){
		if(100*a*i>f) break ;
		for(int j=0;j<=30;j++){
			if(100*(i*a+j*b)<=f) w.insert(100*(i*a+j*b)) ;
			else break ;
		}
	}
	for(int i=0;i<=3000;i++){
		if(i*c>f) break ;
		for(int j=0;j<=3000;j++){
			if(i*c+j*d<=f) s.insert(i*c+j*d) ;
			else break ;
		}
	}
	ll m1,m2;
	m1 = 100*a ;
	m2 = 0 ;
	for(auto i:w){
		if(i==0) continue ;
		for(auto j:s){
			if(i+j>f) continue ;
			if(100*j*(100+e)>(i+j)*100*e) continue ;
			if(100*m2*(i+j)<100*j*m1){
				m1 = i+j ;
				m2 = j ;
			}
		}
	}
	cout << m1 << " " << m2 << endl ;
}


Measured memory_bytes: 384
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
     
using namespace std;
     
typedef long long ll;
typedef pair<int, int> pii;
     
#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
     
mt19937 rnd(chrono::steady_clock().now().time_since_epoch().count());

int main(){
    fastIO;
    int p, q, r;
    cin >> p >> q >> r;
    cout << min({p+q,q+r,p+r});
    return 0;
}


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

int main() {
  int K, S, count = 0;
  cin >> K >> S;

  // K以下の値の3つの組み合わせで合計Sになる
  for (int i = 0; i <= K; i++) {
    for (int j = 0; j <= K; j++) {
      int k = S - i - j;
      if (K >= k && k >= 0) {
        count++;
      }
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

#define MAX 1000

int isTriangle(int a,int b,int c){
	if(a*a == b*b + c*c){
		return 1;
	}else{
		return 0;
	}
}

int main(void){
	int n;
	int i;
	int x,y,z;
	
	scanf("%d", &n);
	
	for(i = 0; i < n; i++){
		scanf("%d%d%d", &x, &y, &z);
		
		if(x > y && x > z){
			if(isTriangle(x,y,z)) printf("YES");
			else printf("NO");
			
		}else if(y > x && y > z){
			if(isTriangle(y,x,z)) printf("YES");
			else printf("NO");
			
		}else{
			if(isTriangle(z,y,x)) printf("YES");
			else printf("NO");
			
		}
		
		puts("");
	}
	
	return 0;
}

Measured memory_bytes: 592
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
// #include<ext/pb_ds/assoc_container.hpp>
// #include<ext/pb_ds/tree_policy.hpp>
// #include<ext/pb_ds/tag_and_trait.hpp>
// using namespace __gnu_pbds;
using namespace std;
using ll=long long;
#define double long double
using datas=pair<ll,ll>;
using ddatas=pair<double,double>;
using tdata=pair<ll,datas>;
using vec=vector<ll>;
using mat=vector<vec>;
using pvec=vector<datas>;
using pmat=vector<pvec>;
// using llset=tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>;
#define For(i,a,b) for(i=a;i<(ll)b;i++)
#define bFor(i,a,b) for(i=a-1;i>=(ll)b;i--)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N,0)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define endl "\n"
#define pb push_back
#define eb emplace_back
#define print(v) cout<<v<<endl
#define printyes cout<<"Yes"<<endl
#define printno cout<<"No"<<endl
#define printYES cout<<"YES"<<endl
#define printNO cout<<"NO"<<endl
#define output(v) do{bool f=0;for(auto outi:v){cout<<(f?" ":"")<<outi;f=1;}cout<<endl;}while(0)
const ll mod=1000000007;
// const ll mod=998244353;
const ll inf=1LL<<60;
const double PI = acos(-1);
const double eps = 1e-9;
template<class T> inline bool chmax(T& a,T b){bool x=a<b;if(x)a=b;return x;} 
template<class T> inline bool chmin(T& a,T b){bool x=a>b;if(x)a=b;return x;} 

void startupcpp(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(15);
}

double distance(ddatas x,ddatas y){
  double a=x.first-y.first,b=x.second-y.second;
  return sqrt(a*a+b*b);
}

ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}

ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}

vec modncrlistp,modncrlistm;

ll modncr(ll n,ll r){
  ll i,size=modncrlistp.size();
  if(size<=n){
    modncrlistp.resize(n+1);
    modncrlistm.resize(n+1);
    if(!size){
      modncrlistp[0]=modncrlistm[0]=1;
      size++;
    }
    For(i,size,n+1){
      modncrlistp[i]=modncrlistp[i-1]*i%mod;
      modncrlistm[i]=modinv(modncrlistp[i]);
    }
  }
  return modncrlistp[n]*modncrlistm[r]%mod*modncrlistm[n-r]%mod;
}

ll modpow(ll a,ll n){
  ll res=1;
  while(n>0){
    if(n&1)res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll gcd(ll a,ll b){if(!b)return a;return (a%b==0)?b:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}

ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}

int main(){
  startupcpp();
  // ll test;cin>>test;while(test--){
  ll i,j,N,H,W,ans;
  double L;
  cin>>L;
  print(pow(L/3.0,3.0));
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<cstdio>
#define ll long long 
using namespace std;
inline int read()
{
	int x=0,f=1;char s=getchar();
	while(s<'0'||s>'9'){if(s=='-')f=-1;s=getchar();}
	while(s<='9'&&s>='0'){x=x*10+s-'0';s=getchar();}
	return x*f;
}
int main()
{
	char ch[50];
	scanf("%s",ch);
	bool flag=true;
	for(int i=1;i<strlen(ch);i++)
		if(ch[i]!='9')flag=false;
	if(flag)printf("%d\n",(strlen(ch)-1)*9+ch[0]-'0');else
		printf("%d\n",(strlen(ch)-1)*9+ch[0]-'0'-1);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

   int tests[testMany];
   int totalTime = 0;

   for(int i = 0; i < testMany; i++) {
      cin >> tests[i];
      totalTime += tests[i];
   }

   int drinkMany;
   cin >> drinkMany;

   int drinks[drinkMany][2];

   for (int d = 0; d < drinkMany; d++) {
      cin >> drinks[d][0]; // テスト番号
      cin >> drinks[d][1]; // テスト時間の更新値
      int testNum = drinks[d][0] - 1;
      int newTime = drinks[d][1];
      int newTotalTime = totalTime - tests[testNum] + newTime;
      cout << newTotalTime << endl;
   }
}

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

#define nl "\n";
int m = 1000000007;
ll ans = 0;
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll n;
	cin >> n;
    long long int ans1 = 1, ans2 = 2, ans3 = 1;
    for(int i=1; i<=n; ++i){
    	ans1 *= 10, ans1 %= m;
    	ans2 *= 9, ans2 %= m;
    	ans3 *= 8, ans3 %= m;
    }
    ans1 -= ans2 - ans3;

	cout << (m+ans1)%m << nl;
	return 0;
}

Measured memory_bytes: 3584
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#include <unordered_map>
typedef long long ll;
using namespace std;
const int mod=1e9+7;
ll solve(){
    int n;
    cin>>n;
    int a[n];
    for(int &i:a) cin>>i;
    ll mx=a[0],ans=0;
    for(int i:a){
        mx=max(mx,(ll)i);
        ans+=(mx-i);
    }
    return ans;
}

int main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
#endif
    int t=1;
    //cin>>t;
    while(t--) cout<<solve()<<'\n';
    //while(t--) solve(),cout<<'\n';
    return 0;
}


Measured memory_bytes: 4396
from bisect import bisect
s = input()
x,y,k,p = [1]*26,[len(s)],1,[[1] for i in range(26)]
for i in range(len(s)-1,-1,-1):
	n = ord(s[i])-97
	x[n] = 0
	p[n].append(-i)
	if sum(x)==0:
		k,x = k+1,[1]*26
		y.append(i)
y,num,ans = y[::-1],0,""
for i in range(k):
	for j in range(97,123):
		if chr(j) not in s[num:y[i]]: break
	ans+=chr(j)
	b = bisect(p[j-97],-y[i])-1
	num = -p[j-97][b]+1
print(ans)

Measured memory_bytes: 12008
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define all(x)              (x).begin(), (x).end()
#define inf                 1e18

using namespace std;
using namespace __gnu_pbds;

template <typename T>
using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
//	ifstream cin("input.txt");
//	ofstream cout("output.txt");
	string a, b, c;
	ll d, e;
	cin >> a >> b >> d >> e >> c;
	cout << d - (c == a) << " " << e - (b == c);
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>


bool is_even(std::string &s) {
    if(s.size()%2) {
        return false;
    }

    int num = s.size() / 2;
    std::string l = "";
    std::string r = "";
    for (int i = 0; i < num; i++)
    {
        l += s[i];
    }

    for (int i = num; i < s.size(); i++) {
        r += s[i];
    }

    if(l == r) {
        return true;
    } else {
        return false;
    }
}

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

    int num = s.size() - 1;
    decltype(s)::iterator it = s.begin() + num;
    num--;
    s.erase(it);
    while (!is_even(s))
    {
        decltype(s)::iterator it = s.begin() + num;
        s.erase(it);
        num--;
    }

    std::cout << s.size() << "\n";
}

Measured memory_bytes: 3596
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String input = scan.next();
		long sum = 0;
		int itr = 1;
		for (int i = 0; i < input.length() - 1; i++) {
			itr *= 2;
		}
		for (int combi = 0; combi < itr; combi++) {
			int i = 0;
			while (i < input.length()) {
				int j = i;
				while ((combi & (1 << j)) == 0) {
					j++;
					if (j >= input.length() - 1) {
						j = input.length() -1;
						break;
					}
				}
				sum += Long.valueOf(input.substring(i, j + 1));
				i = j + 1;
			}
		}
		System.out.println(sum);
	}

}


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

using namespace std;
using ll = long long;
#define int ll
using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define PB push_back

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')';
  return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'[';
  REP(i, a.size()) {out<<a[i];if(i!=a.size()-1)out<<',';}
  out<<']';
  return out;
}

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

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

  int n, c;
  cin >> n >> c;
  VVI d(c, VI(c)), a(n, VI(n));
  REP(i, c) REP(j, c) cin >> d[i][j];
  REP(i, n) REP(j, n) cin >> a[i][j], a[i][j]--;

  VI c1(c), c2(c), c3(c);
  REP(i, n) REP(j, n) {
    if((i+j)%3==0) c1[a[i][j]]++;
    else if((i+j)%3==1) c2[a[i][j]]++;
    else c3[a[i][j]]++;
  }

  int ret = INF;
  REP(i, c) REP(j, c) REP(k, c) {
    if(i == j || j == k || k == i) continue;
    int tmp = 0;
    REP(l, c) tmp += c1[l] * d[l][i];
    REP(l, c) tmp += c2[l] * d[l][j];
    REP(l, c) tmp += c3[l] * d[l][k];
    // cout << endl;
    // cout << i << " " << j << " " << k << " " << tmp << endl;
    chmin(ret, tmp);
  }

  cout << ret << endl;

  return 0;
}


Measured memory_bytes: 2304
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

using namespace std;

//----------------------- Print Function ----------------------//

inline void print() {
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest) {
    cout << first << ' ';
    print(rest...);
}

template <typename T>
void print(const vector<T> &v) {
    for (auto e : v) cout << e << ' ';
    cout << endl;
}

//------------------------- Libraries -------------------------//

//--------------------------- Solve ---------------------------//

void solve() {
    int N, A, B; cin >> N >> A >> B;
    cout << min(A*N, B) << '\n';
}

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

    solve();

    return 0;
}

Measured memory_bytes: 3632
import java.util.Scanner;

public class Main{
	public static void main(String args[]){
		
		long i=0;
		long temp=0;
		long minval=0;
		long maxval=0;
		long sumval=0;

		//long n = new Scanner(System.in).nextInt();

		Scanner scan = new Scanner(System.in);
		long n = Integer.parseInt(scan.next());
		
		for(i=0;i<n;i++){
			temp=Integer.parseInt(scan.next());
			
			if(i==0){
				minval=temp;
				maxval=temp;
				sumval=temp;
			}else{
			
				if(temp<minval){
					minval=temp;
				}
				
				if(maxval<temp){
					maxval=temp;
				}
				
				sumval+=temp;
			}
		}
		
		System.out.println(minval+" "+maxval+" "+sumval);
		
	}
}

Measured memory_bytes: 41892
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1000000000
#define LINF 1000000000000000000
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define bit(n) (1LL<<(n))
using namespace std;

typedef pair<int, int> P;
typedef pair<long long, long long> LLP;

int main() {

    const double PI = acos(-1);

    double A, B, H, M;
    cin >> A >> B >> H >> M;

    double theta_h, theta_m, theta;
    theta_m = 2 * PI * M / 60;
    theta_h = 2 * PI * (H * 60 + M) / (12 * 60);
    theta = abs(theta_h - theta_m);
    theta = min(theta, abs(360 - theta));

    double ans = sqrt(A * A + B * B - 2 * A * B * cos(theta));

    cout << setprecision(20) << ans << endl;
    
    return 0;
}

Measured memory_bytes: 4212
#include <bits/stdc++.h>
#define ll long long
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end))) // rep(i, 1, 5) --> {1,2,3,4} // rep(i, 5, 1) --> {4,3,2,1} // rep(it, end(v), begin(v)) --> *it

using namespace std;

int main()
{
    int n;
    cin >> n;
    int curr = 1;
    bool y = false;
    rep(i, 0, n)
    {
        int a;
        cin >> a;
        if (a == curr)
            curr++;
        if (a == 1)
            y = true;
    }
    if (curr == 1 && y == false)
        cout << -1;
    else if (curr == 1 && y == true)
        cout << 1;
    else 
        cout << n - curr + 1;
    return 0;
}

Measured memory_bytes: 256
#include <iostream> 
#include <cstdio> 
#include <cstdlib> 
#include <cstring> 
#include <cmath> 
#include <algorithm> 
using namespace std; 
const int Mod = 1e9 + 7; 
const int MAX_N = 1e6 + 5; 
int fpow(int x, int y) { 
	int res = 1; 
	while (y) { 
		if (y & 1) res = 1ll * res * x % Mod; 
		x = 1ll * x * x % Mod; 
		y >>= 1; 
	} 
	return res; 
} 
int N = 1e6, M, K; 
int fac[MAX_N], ifc[MAX_N]; 
int C(int n, int m) { 
	if (n < m || n < 0 || m < 0) return 0; 
	else return 1ll * fac[n] * ifc[m] % Mod * ifc[n - m] % Mod; 
} 
int main () { 
	fac[0] = 1; for (int i = 1; i <= N; i++) fac[i] = 1ll * fac[i - 1] * i % Mod; 
	ifc[N] = fpow(fac[N], Mod - 2); 
	for (int i = N - 1; ~i; i--) ifc[i] = 1ll * (i + 1) * ifc[i + 1] % Mod; 
	cin >> N >> M >> K; 
	int ans = 0, sum = 1; 
	int pw = fpow(3, M + K), inv3 = fpow(3, Mod - 2); 
	ans = pw; 
	for (int i = 1; i <= M + K; i++) { 
		pw = 1ll * pw * inv3 % Mod; 
		sum = (sum + sum) % Mod; 
		if (i > M) sum = (sum - C(i - 1, i - M - 1) + Mod) % Mod; 
		if (i > K) sum = (sum - C(i - 1, K) + Mod) % Mod; 
		ans = (ans + 1ll * pw * C(N - 1 + i, N - 1) % Mod * sum) % Mod; 
	} 
	printf("%d\n", ans); 
    return 0; 
} 

Measured memory_bytes: 8064
## TLE
class UnionFind():
    def __init__(self, n):
        self.n = 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
    
    def same(self, x, y):
        return self.find(x) == self.find(y)
      
n,m = map(int,input().split())
P = list(map(int,input().split()))

uf = UnionFind(n)

for i in range(m):
  a,b = map(int,input().split())
  uf.union(a-1,b-1)

ans = 0  
for i in range(n):
  if uf.same(P[i]-1,i):
    ans += 1

print(ans)  

Measured memory_bytes: 14452
N = gets.to_i
A = 2.times.map{gets.split.map(&:to_i)}

count = 0
N.times do |i|
  x = (0..i).map{|i|A[0][i]}.inject(:+)
  y = (i...N).map{|i|A[1][i]}.inject(:+)
  count = x + y if count < x + y
end
puts count

Measured memory_bytes: 1916
#include<iostream>

using namespace std;

int cnt[2];

int main(){
    string S;   
    cin >> S;
    for(int i=0; i<=S.length()-1; i++){
        if(S[i] == 'S'){
            cnt[1]++;
        } else{
            if(cnt[1] > 0){
                cnt[1]--;
            } else{
                cnt[2]++;
            }
        }
    }
    cout << cnt[1] + cnt[2] << endl;
}

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
typedef long long ll;


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

    int a = 0;
    REP(i,S.size()){
        if(i%2 == S[i]-'0'){
            a++;
        }
    }

    cout << min(a, (int)(S.size()-a)) << endl;

    return 0;
}

Measured memory_bytes: 3732
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <stack>

#define pb push_back
#define ins insert
#define pob pop_back
#define er erase
#define emp empty
#define f first
#define s second
#define ff f.f
#define fs f.s
#define sf s.f
#define ss s.s
#define var auto

using namespace std;
template<typename  T>
using s = set<T>;
template<typename T>
using  v = vector<T>;
template<typename T1, typename  T2>
using p = pair < T1, T2>;
typedef long long ll;
typedef p<int, int> pii;
typedef v<int> vi;
typedef v<pii> vpii;
typedef s<int> si;
typedef s<pii> spii;


const int Max = 1e5 + 100;
const int MOD = 1e9 + 7;
const ll INF = 1e18;

int n, k;
bool dp[Max];
ll A[Max];

int main()
{
	cin >> n >> k;
	for (int i = 0; i < n; i++)
		cin >> A[i];
	//He Cant Do Any Move So Lose
	dp[0] = false;
	for (int i = 1; i <= k; i++)
	{
		bool foundLoose = false;
		for (var s : A)
		{
			if (s == 0)
				break;
			if (i >= s)
			{
				foundLoose = !dp[i - s];
			}
			if (foundLoose)
				break;
		}
		dp[i] = foundLoose;
	}

	if (dp[k])
		cout << "First";
	else
		cout << "Second";
}


Measured memory_bytes: 384
x=int(input(''))
y=[0]*x
for i in range(x):
  y[i]=input('')
a=0
w=0
t=0
r=0
for i in range(x):
  if y[i]=='AC':
    a=a+1
  elif y[i]=='WA':
    w=w+1
  elif y[i]=='TLE':
    t=t+1
  else:
    r=r+1
print('AC x {0}\nWA x {1}\nTLE x {2}\nRE x {3}'.format(a,w,t,r))

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

int main(){
  int n;
  cin >> n;
  vector<int> vn(n);
  for(int i=0; i<n; ++i) cin >> vn[i];
  map<int, int> mp1, mp2;
  int mxn11 =0, mxn12 =0, mp1mx =0;
  for(int i=0; i<n; i += 2){
    ++mp1[vn[i]];
    int x = mp1[vn[i]];
    if(x > mxn11){
      int y = mxn11;
      mxn11 = x;
      if(mp1mx != vn[i]){
        mp1mx = vn[i];
        if(y > mxn12) mxn12 = y;
      }
    }
    else if(x > mxn12) mxn12 = x;
  }
  int mxn21 =0, mxn22 =0, mp2mx =0;
  for(int i=1; i<n; i += 2){
    ++mp2[vn[i]];
    int x = mp2[vn[i]];
    if(x > mxn21){
      int y = mxn21;
      mxn21 = x;
      if(mp2mx != vn[i]){
        mp2mx = vn[i];
        if(y > mxn22) mxn22 = y;
      }
    }
    else if(x > mxn22) mxn22 = x;
  }
  if(mp1mx != mp2mx) cout << n -mxn11 -mxn21 << endl;
  else cout << n - max(mxn12 +mxn21, mxn11 +mxn22) << endl;
}

Measured memory_bytes: 8128
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

bool isLower( char c ){
	return ( c >= 'a' && c <= 'z' )? true : false ;
}

bool isUpper(char c){
	return ( c >= 'A' && c <= 'Z' )? true : false ;
}

vector<string> splitString(const string& s){
	string s_ = "";
	vector<string> vc;

	for(int i=0 ; i<(int)s.size() ; i++ ){
		if( s[i] == '_' ){
			vc.push_back( s_ );
			s_ = "";
		}else if( isLower( s[i] ) ){
			s_.push_back( s[i] );
			if( i == (int)s.size()-1 ){
				vc.push_back( s_ );
			}
		}else if( isUpper( s[i] ) ){
			vc.push_back( s_ );
			s_ = "";
			s_.push_back( s[i] );
			if( i == (int)s.size()-1 ){
				vc.push_back( s_ );
			}
		}
	}
	return vc;
}

string solve(string s, string c){
	vector<string> vc = splitString( s );
	string str = "";
	
	for(int i=0 ; i<(int)vc.size() ; i++ ){
		if( !vc[i].empty() ){
			if( c == "D" ){
				if( isUpper(vc[i][0]) )
					vc[i][0] += 'a'-'A';
				str += vc[i];
				if( i != (int)vc.size()-1 )
					str.push_back('_');
			}else{
				if( isLower(vc[i][0]) )
					vc[i][0] -= 'a'-'A';
				str += vc[i];
			}
		}
	}
	if( c == "L" && isUpper(str[0]) ){
		str[0] += 'a'-'A';
	}
	return str;
}

int main(){
	string s, c;
	while( cin >> s >> c , c != "X" ){
		cout << solve( s , c ) << endl;
	}
}

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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;

#define f first
#define s second
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define pb push_back

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) FOR(i, 0, a)
#define ROF(i, a, b) for (int i = (b); i >= (a); i--)
#define R0F(i, a) ROF(i, 0, a-1)
#define trav(x, a) for (auto& x: a)

const int MX  = 2e5+5;
const int MOD = 1e9+7;
const ll  INF = 1061109567; // 4557430888798830399LL
const ld  EPS = 1e-9;
const ld  PI  = acos(-1);

int arr[MX];
bool dp[MX];

int main() {

    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    int N,K; cin >> N >> K;

    F0R(i,N) cin >> arr[i];

    dp[0] = 1;
    FOR(i,1,K+1) {
        dp[i] = 1;
        F0R(x,N) {
            if (i-arr[x] >= 0) dp[i] = min(dp[i],!dp[i-arr[x]]);
        }
    }

    cout << (!dp[K] ? "First\n" : "Second\n");

}


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

int read() {
    int x = 0, f = 1; char ch = getchar();
    while (!isdigit(ch)) { if (ch == '-') f = -1; ch = getchar(); }
    while (isdigit(ch)) { x = x * 10 + ch - '0'; ch = getchar(); }
    return x * f;
}

const int Max = 100033;
int n, a[Max], b[Max], c[Max], d[Max], fa[Max], cnt, ans;
map<int, int> id;
int find(int x) {
    return x == fa[x] ? x : fa[x] = find(fa[x]);
}

int main() {
    n = read();
    for (int i = 1; i <= n; i++) a[i] = c[i] = read();
    for (int i = 1; i <= n; i++) b[i] = d[i] = read();
    for (int i = 1; i <= n; i++) {
        c[n + 1] = a[n + 1] ^= a[i];
        d[n + 1] = b[n + 1] ^= b[i];
    }
    n++;
    sort(c + 1, c + n + 1), sort(d + 1, d + n + 1);
    for (int i = 1; i <= n; i++)
        if (c[i] != d[i]) {
            puts("-1"); return 0;
        }
    for (int i = 1; i < n; i++)
        if (a[i] != b[i]) {
            ans++;
            if (!id[a[i]]) id[a[i]] = ++cnt;
            if (!id[b[i]]) id[b[i]] = ++cnt;
        }
    if (!id[a[n]]) id[a[n]] = ++cnt;
    if (!id[b[n]]) id[b[n]] = ++cnt;
    if (!ans) { puts("0"); return 0; }
    for (int i = 1; i <= cnt; i++) fa[i] = i;
    for (int i = 1; i <= n; i++)
        if (a[i] != b[i])
            fa[find(id[a[i]])] = find(id[b[i]]);
    for (int i = 1; i <= cnt; i++)
        if (find(i) == i) ans++;
    cout << ans - 1 << endl;
    return 0;
}

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

"""
参考：https://img.atcoder.jp/abc122/editorial.pdf
・数え上げDP
・正規表現
"""

import sys, re
from itertools import product
from collections import Counter

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N=INT()

# NGパターン一覧
patterns = [
    # 任意の0か1文字
    re.compile(r'^(.?)AGC(.?)$'),
    re.compile(r'^(.?)GAC(.?)$'),
    re.compile(r'^(.?)ACG(.?)$'),
    # 任意の1文字
    re.compile(r'^A.GC$'),
    re.compile(r'^AG.C$'),
]

# dp[i][j] := 全部でi文字の時、最後の3文字がjとなる文字列の数
dp=[Counter() for i in range(N+1)]
keys = [''.join(key) for key in product('ACGT', repeat=3)]
# 3文字での初期値
for key in keys:
    if key not in ['AGC', 'GAC', 'ACG']:
        dp[3][key]=1

keys = [''.join(key) for key in product('ACGT', repeat=4)]
for i in range(4, N+1):
    for key in keys:
        # NGパターンのいずれにもマッチしないものだけ遷移させる
        if not any([ptn.match(key) for ptn in patterns]):
            cur,nxt=key[:3],key[1:]
            dp[i][nxt]=(dp[i][nxt]+dp[i-1][cur])%MOD
print((sum(dp[N].values()))%MOD)


Measured memory_bytes: 4340
using System;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleApp1
{
    class Program
    {
        public static int GetInt()
        {
            int a = int.Parse(Console.ReadLine());
            return a;
        }

        public static int[] GetIntArray()
        {
            var a = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            return a;
        }

        static void Main(string[] args)
        {
            var a = GetIntArray();
            var N = a[0];
            var M = a[1];
            var C = a[2];

            var B = GetIntArray();

            int ans = 0;

            for(int i = 0; i < N;i++)
            {
                var A = GetIntArray();
                int sum = 0;
                for(int j = 0; j < M; j++)
                {
                    sum = sum + A[j] * B[j];
                }
                if(sum + C > 0)
                {
                    ans = ans + 1;
                }
            }

            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 11348
Node = Struct.new(:key, :priority, :left, :right)

class Tree
  def initialize
    @root = nil
  end
  
  def insert(key, priority)
    unless @root
      @root = Node.new(key, priority)
      return
    end
    insert = ->(node) {
      return Node.new(key, priority) unless node
      return node if key == node.key
      if key < node.key
        node.left  = insert.(node.left)
        node = right_rotate(node) if node.priority < node.left.priority
      else
        node.right = insert.(node.right)
        node = left_rotate(node)  if node.priority < node.right.priority
      end
      node
    }
    @root = insert.(@root)
  end
  
  def search(key)
    node = @root
    while node
      if key < node.key
        node = node.left
      elsif key > node.key
        node = node.right
      else
        return node
      end
    end
    nil
  end
  
  def delete(key)
    delete1 = nil
    
    delete = ->(node) {
      return nil unless node
      if key < node.key
        node.left  = delete.(node.left)
      elsif key > node.key
        node.right = delete.(node.right)
      else
        return delete1.(node)
      end
      node
    }
    delete1 = ->(node) {
      return nil if !node.left and !node.right
      node = if node.left.nil?
        left_rotate(node)
      elsif node.right.nil?
        right_rotate(node)
      else
        if node.left.priority > node.right.priority
          right_rotate(node)
        else
          left_rotate(node)
        end
      end
      delete.(node)
    }
    @root = delete.(@root)
  end
  
  def right_rotate(node)
    tmp = node.left
    node.left = tmp.right
    tmp.right = node
    tmp
  end
  
  def left_rotate(node)
    tmp = node.right
    node.right = tmp.left
    tmp.left = node
    tmp
  end
  
  def preorder
    traverse = ->(node) {
      if node
        yield(node.key)
        traverse.(node.left)
        traverse.(node.right)
      end
    }
    traverse.(@root)
  end
  
  def inorder
    traverse = ->(node) {
      if node
        traverse.(node.left)
        yield(node.key)
        traverse.(node.right)
      end
    }
    traverse.(@root)
  end
end

t = Tree.new

$<.gets.to_i.times do
  com, key, priority = $<.gets.split
  key = key.to_i
  priority = priority.to_i
  case com
  when "insert" then t.insert(key, priority)
  when "print"
    t.inorder  {|key| print " #{key}"}
    puts
    t.preorder {|key| print " #{key}"}
    puts
  when "find"
    puts t.search(key) ? "yes" : "no"
  when "delete" then t.delete(key)
  end
end


Measured memory_bytes: 28124
def knapsack(sizes, vals, volume):
    n = len(sizes)

    dp = [[0] * (volume+1) for _ in range(n)] # j is 0...volume

    for i in range(n):
        for j in range(volume+1):
            dp[i][j] = max(dp[i][j], dp[i-1][j])
            if j - sizes[i] >= 0:
                dp[i][j] = max(dp[i][j], dp[i-1][j-sizes[i]] + vals[i])
            #dp[i][j] = max(dp[i][j], dp[i-1][j])

    return dp[-1][-1]


if __name__ == "__main__":
    n, volume = [int(x) for x in input().split()]
    sizes, vals = [], []
    for _ in range(n):
        s, v = [int(x) for x in input().split()]
        sizes.append(s)
        vals.append(v)
    print(knapsack(sizes, vals, volume))


Measured memory_bytes: 119280
#include <functional>
#include <algorithm>
#include <stdexcept>
#include <iostream>
#include <sstream>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <cctype>
#include <vector>
#include <string>
#include <bitset>
#include <cmath>
#include <queue>
#include <stdio.h>
#include <stack>
#include <ctime>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <assert.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define TR(i,x) for(__typeof(x.begin()) i=x.begin();i!=x.end();i++)
#define ALL(x) x.begin(),x.end()
#define SORT(x) sort(ALL(x))
#define CLEAR(x) memset(x,0,sizeof(x))
#define FILL(x,c) memset(x,c,sizeof(x))
#define PB push_back
#define MP make_pair

using namespace std;

const double eps = 1e-8;

typedef map<int,int> MII;
typedef map<string,int> MSI;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<long double> VD;
typedef pair<int,int> PII;
typedef long long int64;
typedef long long LL;
typedef unsigned int UI;
typedef long double LD;

int main() {
    int n;
    cin >> n;
    while (n > 0) {
        if (n % 10 == 7) {
            cout << "Yes" << endl;
            return 0;
        }
        n /= 10;
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
#define For(i,n) for(int i=0; i<n;i++)
#define whatis(x) cerr<<#x<<" is " << x<<endl;
using namespace std;

int main(){
    #ifdef magUNbos
    freopen("in","r",stdin);
    freopen("out","w",stdout);
    #endif // magUNbos

    int n,m; cin>>n>>m;
    int a[n+1];
    For(i,n+1)
        a[i]=1;
    a[1]=-1;
    For(i,m){
        int X,Y;
        cin>>X>>Y;

        if(a[X]<0){
            a[X]++;
            if(a[Y]<0){
                a[Y]--;
            }
            else{
            a[Y]++;
            a[Y]*=-1;
            }

        }
        else{
            a[X]--;
            if(a[Y]<0)
                a[Y]--;
            else
                a[Y]++;
        }
    }
    int ans =0;
    For(i,n+1){
        if(a[i]<0){
            ans++;

    }
    }
    cout<<ans<<'\n';

}



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

int outv(int a, int b, int v){ if(a==v){ return b; }else{ return a; } }
int main(){
int i, j, k, N, K, s; cin >> N;
vector<int> a(N), b(N); vector< vector<int> > eg(N+1);
for(i=1; i<N; i++){ cin >> a[i] >> b[i]; eg[a[i]].push_back(i); eg[b[i]].push_back(i); }
for(K=i=1; i<=N; i++){ s=eg[i].size(); K=max(K, s); }

vector<int> V(1), E(1), c(N); V[0]=1; E[0]=0; int v, e, nv;
vector<bool> table(N+1); table[1]=true;
for(i=0; i<V.size(); i++){
  for(v=V[i], j=0; j<eg[v].size(); j++){
    e=eg[v][j]; nv=outv(a[e], b[e], v);
    if(!table[nv]){ V.push_back(nv); E.push_back(e); table[nv]=true; }
  }
}
for(i=0; i<V.size(); i++){
  for(v=V[i], k=1, j=0; j<eg[v].size(); j++){
    if(c[E[i]]==k){ k++; }
    e=eg[v][j]; if(e!=E[i]){ c[e]=k; k++; }
  }
}
for(c[0]=K, i=0; i<N; i++){ cout << c[i] << "\n"; }
}

Measured memory_bytes: 8100
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <numeric>
#include <cmath>

#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
using P = pair<int, int>;

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

const ll MOD = 1000000007;
const int INF = 1<<30;
//const ll INF = (ll)1e18 + 1;

using Graph = vector<vector<int>>;
int main(){
  int N, M; cin >> N >> M;
  Graph G(N);
  for (int i = 0; i < M; ++i){
    int u, v; cin >> u >> v; --u, --v;
    G[u].push_back(v);
  }
  int S, T; cin >> S >> T;
  --S, --T;

  //-----------------//
  // pair<node, mod3>
  vector<vector<ll>> dist(N, vector<ll>(3, -1));
  dist[S][0] = 0;
  queue<P> que;
  que.push({S, 0});
  while (!que.empty()){
    P cur = que.front(); que.pop();
    int v = cur.first;
    int parity = cur.second;
    for (auto nv : G[v]){
      int np = (parity + 1) % 3;
      if (dist[nv][np] == -1){
        dist[nv][np] = dist[v][parity] + 1;
        que.push({nv, np});
      }
    }
  }
  if (dist[T][0] == -1) cout << -1 << endl;
  else cout << dist[T][0] / 3 << endl;
}


Measured memory_bytes: 11136
#pragma GCC optimize("Ofast")


#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<limits.h>
#include<cmath>
#include<queue>
#include<stack>

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

#define rep(i,n) for(ll i = 0; i < (ll)n; i++)
#define swap(a,b) a^=b;b^=a;a^=b;
#define chmax(a,b) {if(a < b) a = b;}
#define chmin(a,b) {if(a > b) a = b;}

using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;

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

	//Program Start	
	ll N, D;
	cin >> N >> D;

	int ans = 0;

	rep(i, N) {
		ll X, Y;
		cin >> X >> Y;
		if(X * X + Y * Y <= D * D)
			ans ++;
	}

	cout << ans << endl;


EndPoint:;

	//Program End
#ifndef DEBUG
	system("read -p 'Press enter'");
#endif // !DEBUG

	return 0;
}




Measured memory_bytes: 3716
#include <stdio.h>
#include <stdlib.h>

/* run this program using the console pauser or add your own getch, system("pause") or input loop */

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

	int x;
	scanf("%d",&x);
	if (x>0 && x <=3000) 
	{
	if (x<1200) { printf("ABC"); }
	else printf("ARC");
	}
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<queue>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<map>
#include<set>
//#include <Eigen/Dense>
//#include <Eigen/Geometry>
//using namespace Eigen;

using namespace std;




int main() 
{
	int s, w;
	cin >> s >> w;
	if (w >= s)
		cout << "unsafe" << endl;
	else
		cout << "safe" << endl;
	return 0;
}


Measured memory_bytes: 3624
using System;
using System.Linq;
using System.Collections.Generic;

class Mondai
{
    static void Main()
    {
        var pqr = Console.ReadLine().Split(' ').Select(x => Int32.Parse(x)).ToArray();
        var P = pqr[0];
        var Q = pqr[1];
        var R = pqr[2];
        var array = new int[6];
        array[0] = P + Q;
        array[1] = R + Q;
        array[2] = P + R;
        array[3] = Q + R;
        array[4] = R + P;
        array[5] = Q + P;
        var ans=array.Min();
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 13396
import java.util.*;

public class Main {

    static final int MOD = 1000000007;

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt(),b=sc.nextInt();
        System.out.println(a<9&&b<9?"Yay!":":(");
    }
}


Measured memory_bytes: 21332
#include<iostream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<string>
#include<cstring>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<bitset>
#define endl "\n"
using namespace std;

int main()
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  char a, b;
  cin >> a >> b;
  if (a == b)
  {
    cout << "H" << endl;
  }
  else
  {
    cout << "D" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
 
char s[101],p[101];
char S[202];
 
main()
{
    scanf("%s",s);
    scanf("%s",p);
     
    strcpy(S,s);
    strcat(S,s);
     
    if(strstr(S,p)!=NULL){
    printf("Yes\n");
    }
     
    else{
    printf("No\n");
    }
     
    return 0;
}


Measured memory_bytes: 2144
#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() {
  int n;
  cin >> n;
  ll V = 0, E = 0;
  for (int i = 1; i <= n; ++i) V += ll(i) * (n - i + 1);
  rep(i, n - 1) {
    int a, b;
    cin >> a >> b;
    if (a > b) swap(a, b);
    E += ll(a) * (n - b + 1);
  }
  ll ans = V - E;
  cout << ans << endl;
  return 0;
}

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

int N, K, W[100000];
int ans = 0;

bool load(int P)
{
	int A = K - 1, B = P;
	for(int i = 0; i < N; ++i)
	{
		if(B >= W[i])
		{
			B -= W[i];
		}
		else if(P < W[i])
		{
			A = -1;
			break;
		}
		else
		{
			B = P - W[i];
			--A;
			
			if(A < 0)
			{
				break;
			}
		}
	}
	
	return (A >= 0);
}

void bsearch(int l, int r)
{
	if(l > r)
	{
		return;
	}
	
	int mid = (l + r) / 2;
	if(load(mid))
	{
		if(mid < ans)
		{
			ans = mid;
		}
		
		bsearch(l, mid - 1);
	}
	else
	{
		bsearch(mid + 1, r);
	}
}

int main()
{
	int sum = 0;
	
	cin >> N >> K;
	for(int i = 0; i < N; ++i)
	{
		cin >> W[i];
		sum += W[i];
	}
	
	ans = sum;
	bsearch(0, sum);
	cout << ans << endl;

    return 0;
}



Measured memory_bytes: 3496
M, D = map(int, input().split())

count = 0
for m in range(1, M+1):
    for d in range(1, D+1):
        d10, d1 = divmod(d, 10)
        if d1 >= 2 and d10 >= 2 and d1*d10 == m:
            count += 1
print(count)


Measured memory_bytes: 2940
fun main(args: Array<String>) = yorukatsu11e()

fun yorukatsu11e() {
    val (n, m) = readLine()!!.split(' ').map { it.toInt() }
    val edges = Array(m) {
        readLine()!!.split(' ').map { it.toInt() - 1 }.let { Edge(it[0], it[1]) }
    }

    val graph = Array(n) { Vertex(it) }
    edges.forEach {
        val (from, to) = it
        graph[from].neighbor.add(to)
        graph[to].neighbor.add(from)
    }

    val permutations = permutations((0 until n).toList())
        .filter { it[0] == 0 }

    val answer = permutations.count { paths ->
        (0 until n - 1).all { graph[paths[it]].neighbor.contains(paths[it + 1]) }
    }

    println(answer)
}

private data class Edge(val from: Int, val to: Int)
private data class Vertex(val index: Int, val neighbor: MutableSet<Int> = mutableSetOf())

private fun permutations(src: List<Int>): List<List<Int>> {
    if (src.size == 1) return listOf(src)
    val perms = mutableListOf<List<Int>>()
    val insertElement = src[0]
    permutations(src.drop(1)).forEach { perm ->
        for (i in 0..perm.size) {
            val newPerm = perm.toMutableList()
            newPerm.add(i, insertElement)
            perms.add(newPerm.toList())
        }
    }
    return perms
}


Measured memory_bytes: 48388
function Main(input) {
    // 1行目がinput[0], 2行目がinput[1], …に入る
    
    A = Number(input.split(" ")[0]);
    B = Number(input.split(" ")[1]);
    C = Number(input.split(" ")[2]);
    
    if(B/A >= C){
        answer = C

    }else{
        answer = Math.floor(B/A)
    }
    console.log(answer);
}
    

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));




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

int n, k;
vector<int> g[2055];

int calc(int v, int par, int d) {
	int ret = 0;
	
	if (d < 0) ret++;
	
	for (auto u : g[v]) {
		if (u == par) continue;
		ret += calc(u, v, d - 1);	
	}
	
	return ret;
}
int main() {
	scanf("%d %d", &n, &k);
	
	int x, y;
	
	for (int i = 0; i < n - 1; i++) {
		scanf("%d %d", &x, &y);
		x--, y--;
		
		g[x].push_back(y);
		g[y].push_back(x);	
	}
	
	int res = n;

	if (k & 1) {
		for (int i = 0; i < n; i++) {
			for (auto w : g[i]) {
				res = min(res, calc(i, w, k / 2) + calc(w, i, k / 2));
			}
		}
	} else {
		for (int i = 0; i < n; i++) {
			res = min(res, calc(i, -1, k / 2));
		}
	}
	
	printf("%d\n", res);
	
	return 0;	
}

Measured memory_bytes: 512
#include<iostream>
#include<cmath>
#include<algorithm>
#include<iomanip>
#include<string>
#include<vector>
#include<cstdio>
#include<cstring>
#include<map>
#include<set>
#include<fstream>
#include<sstream>
#include<queue>
#include<iterator>
#include<stack>

using namespace std;

#define st first
#define nd second
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REV(a) reverse(a.begin(),a.end())
#define SORT(a) sort(a.begin(),a.end())
#define inf (int)1e9
#define linf (long long)1e18

typedef long long ll;
typedef short int si;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef vector<pli> vpli;

int main() {
		int n,m,k;
		cin>>n>>m>>k;
		FOR(i,0,n+1){
				FOR(j,0,m+1){
						if(i*j+(n-i)*(m-j)==k){
								cout<<"Yes\n";
								return 0;
						}
				}
		}
		cout<<"No\n";





		return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
using namespace std;

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

    bool check_TG[n + 1];
    for(int i = 0; i < n + 1; i++){
        check_TG[i] = false;
    }
    for(int i = 0; i < m; i++){
        check_TG[a[i]] = true;
    }

    int count_l = 0;
    for(int i = x; i >= 0; i--){
        if(check_TG[i]){
            count_l++;
        }
    }
    int count_r = 0;
    for(int i = x; i <= n; i++){
        if(check_TG[i]){
            count_r++;
        }
    }
    printf("%d\n",min(count_l,count_r));

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define debug(x) cerr << #x << ": " << x << '\n'
 
typedef long long int ll;
typedef pair<int, int> P;
 
const long long INF = 3e18 + 12;
const int inf = 1e9;
 
int main() {
  ll n, y;
  cin >> n >> y;
  ll k = y / 1000;
 
  rep(i, n + 1) {
    rep(j, n + 1) {
      if (9 * i + 4 * j == k - n) {
        if (n - i - j >= 0) {
          cout << i << " " << j << " " << n - i - j << endl;
          return 0;
        }
      }
    }
  }
  cout << "-1 -1 -1" << endl;
 
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
int main()
{
    int a,b,c,sum,maxn;
    scanf("%d%d%d",&a,&b,&c);
    maxn=max(a,max(b,c));
    sum=a+b+c-maxn;
    printf("%d",sum);
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
	int n, k;
	cin >> n;
	int c = 0;
	for (int i = 0; i < n; ++i) {
		cin >> k;
		while (0 == k % 2) {
			k /= 2;
			++c;
		}
	}
	cout << c << endl;
	return 0;
}

Measured memory_bytes: 256
#D問題

#ビットごとに考えられる
k=10**9+7

anslist=[]

n=int(input())
a=[format(int(i), '060b') for i in input().split()]
d=[]

for i in range(60):
    b=[j[59-i] for j in a]
    c=b.count("0")*b.count("1")
    d.append(c*2**(i)%k)
ans=0

for i in d:
    ans+=i
print(ans%k)

Measured memory_bytes: 65708
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include<math.h>
using namespace std;
#define INF 1100000000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<int,int> P;

vector<int> V[330000]; 
int d[330000];
int N,M,u,v,S,T;


void bfs(){
  queue<P> que;
  d[S]=0;
  que.push(P(S,0));

  while(que.size()){
    P p=que.front(); que.pop();
    for(int i=0;i<(int)V[p.first].size();i++){
      int np=V[p.first][i];
      if(d[np]==0){
          d[np]=p.second+1;
          que.push(P(np,p.second+1));
          //cout<<np<<" "<<d[np]<<endl;
      }
    }
  }

  return;
}


int main(){
    cin>>N>>M;
    for(int i=0;i<M;i++){
        cin>>u>>v;
        u--;
        v--;
        V[u].push_back(v+N);
        V[u+N].push_back(v+2*N);
        V[u+2*N].push_back(v);
    }
    cin>>S>>T; S--; T--;

    bfs();

    if(d[T]==0) cout<<-1<<endl;
    else cout<<d[T]/3<<endl;


}


Measured memory_bytes: 18560
def enum_divisors(n):
    res = []
    a = 2
    while a*a <= n:
        if n % a == 0:
            e = 0
            while n % a == 0:
                e += 1
                n //= a
            res.append((a,e))
        a += 1
    
    if n != 1:
        res.append((n,1))

    return res

n = int(input())
enums = enum_divisors(n)
ans = 0
for i in enums:
    e = i[1]
    j = 0
    while e >= 0:
        j += 1
        e -= j

    ans += j - 1

print(ans)



Measured memory_bytes: 9180
#include "bits/stdc++.h"
#define _USE_MATH_DEFINES
#include <math.h>
 
using namespace std;
 
using LL = long long;
using VLL = std::vector<LL>;
using VVLL = std::vector<VLL>;
using VVVLL = std::vector<VVLL>;
using LD = long double;
using VLD = std::vector<LD>;
using VVLD = std::vector<VLD>;
using VVVLD = std::vector<VVLD>;
 
template<class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; }return false; }

//template<class T=LL> inline vector<T> cinv(LL N){ vector<T> v(N); REP(i, N)cin>>v[i]; return move(v);}
//template<class T=LL> inline vector<T> cinv(LL N){ vector<T> v(N); REP(i, N)cin>>v[i]; return move(v);}
#define REP(i,n) for(LL (i)=0;(i)<(n);(i)++)
#define ALL(v) v.begin(), v.end()
#define PRINTLN(v) {LL i=0; for(auto (a): v ){   cerr <<i << " : "<<  a << endl; i++;}}
#define PRINTSP(v) for(auto (a): v ) {cerr << a << " ";} cerr << endl
#define cmax(a,b) {if(a<b){a=b;}}
#define cmin(a,b) {if(a>b){a=b;}}
#define EACH(a,A) for(auto a: A)
//#define cmax(a,b) a = (a>b ? a:b)
//#define cmin(a,b) a = (a<b ? a:b) 
//cin,cout高速化のおまじない＋桁数指定
inline VLL cinvll(LL N){
  VLL A(N);
  REP(i,N){
    cin >> A[i];
  }
  return move(A);
}
struct Fast{
	Fast(){
		cin.tie(0);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(std::numeric_limits<double>::max_digits10);
	}
} fast;


VLL F;
VLL S{100,101,102,103,104,105};

void memo(LL yen){
  for(auto s : S){
    if(yen-s>=0 and F[yen-s]==1){
      F[yen]=1;
    }
  }
}

void func(){
  LL X;
  cin >> X;
  F.resize(1e6+10,0);

  F[100]=1;
  F[101]=1;
  F[102]=1;
  F[103]=1;
  F[104]=1;
  F[105]=1;
  REP(i,X+1){
    memo(i);
  }  
  //PRINTLN(F);
  cout <<F[X];
  //LL N;
  //cin >> N;
  //auto A = cinvll(N);
  //PRINTSP(A);

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

Measured memory_bytes: 8064