akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
typedef long long ll;
#define MOD 1000000007
using namespace std;
int main() {
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }
    //コーナーケース
    if(n == 1) {
        cout << (a[0] < k) << endl;
        return 0;
    }
    if(n == 2) {
        int ans = 0;
        if(a[1] >= k) {
            ans++;
        }
        if(a[0] >= k) {
            ans++;
        }
        cout << ans << endl;
        return 0;
    }
    vector<vector<bool>> dpf(n + 2, vector<bool>(5002, false));
    vector<vector<bool>> dpb(n + 2, vector<bool>(5002, false));
    dpf[0][0] = true;
    for(int i = 1; i <= n; i++) {
        for(int j = 0; j < 5002; j++) {
            dpf[i][j] = dpf[i - 1][j];
            if(j - a[i - 1] >= 0 && dpf[i - 1][j - a[i - 1]]) {
                dpf[i][j] = true;
            }
        }
    }
    dpb[n + 1][0] = true;
    for(int i = n; i >= 1; i--) {
        for(int j = 0; j < 5002; j++) {
            dpb[i][j] = dpb[i + 1][j];
            if(j - a[i - 1] >= 0 && dpb[i + 1][j - a[i - 1]]) {
                dpb[i][j] = true;
            }
        }
    }
    vector<vector<int>> front(n + 2), back(n + 2);
    for(int i = 1; i <= n; i++) {
        for(int k = 0; k < 5002; k++) {
            if(dpf[i][k]) {
                front[i].push_back(k);
            }
            if(dpb[i][k]) {
                back[i].push_back(k);
            }
        }
    }
    int ans = 0;
    // 1番目が必要かどうか
    auto itr = lower_bound(all(back[2]), k - a[0]);
    if(itr != back[2].end() && *itr < k) {
        ans++;
    }
    // n番目が必要かどうか
    itr = lower_bound(all(front[n - 1]), k - a[n - 1]);
    if(itr != front[n - 1].end() && *itr < k) {
        ans++;
    }
    for(int i = 2; i < n; i++) {
        int tmp = 0;
        for(auto x : front[i - 1]) {
            auto itr2 = lower_bound(all(back[i + 1]), k - a[i - 1] - x);
            if(itr2 != back[i + 1].end() && *itr2 < k - x) {
                tmp = 1;
            }
        }
        ans += tmp;
    }
    cout << n - ans << endl;
}

Measured memory_bytes: 240896
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Abc
{
    class QuestionC
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            //// 文字列の入力
            //string s = Console.ReadLine();

            //// 整数の入力
            //long n = long.Parse(Console.ReadLine());

            //// 文字列配列の入力
            //string[] inputStrArray = Console.ReadLine().Split(' ');

            //// 整数配列の入力
            //var inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();

            var inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
            long n = long.Parse(Console.ReadLine());

            var volume = n;

            var Q = inputLongArray[0];
            var H = inputLongArray[1];
            var S = inputLongArray[2];
            var D = inputLongArray[3];

            var ones = new List<long>();

            ones.Add(S);
            ones.Add(H * 2);
            ones.Add(H + Q * 2);
            ones.Add(Q * 4);

            var one = ones.Min();

            var twos = new List<long>();

            twos.Add(D);
            twos.Add(S * 2);
            twos.Add(S + H * 2);
            twos.Add(S + H + Q * 2);
            twos.Add(S + Q * 4);
            twos.Add(H * 4);
            twos.Add(H * 3 + Q * 2);
            twos.Add(H * 2 + Q * 4);
            twos.Add(H * 1 + Q * 6);
            twos.Add(Q * 8);

            var two = twos.Min();

            long result = 0;

            if (n % 2 == 0) {
                var nn = n / 2;
                result = nn * two;
            } else {
                var nn = n / 2;
                result = nn * two + one;
            }

            Console.WriteLine(result.ToString());

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 13396
#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>;
const int INF = INT32_MAX;
const ll INFL = INT64_MAX;
const int mod = 1e9;

template <typename T>
void print_vec(vector<T> v) {
  for (T i : v) cout << i << " ";
  cout << endl;
}

int main() {
  int n;
  cin >> n;
  vector<int> p(n);
  rep(i, n) cin >> p[i];
  int ans = 0;
  for (int i = 1; i < n - 1; i++) {
    if (p[i - 1] < p[i] && p[i] <= p[i + 1])
      ans++;
    else if (p[i + 1] < p[i] && p[i] <= p[i - 1])
      ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <numeric>
#define rep(i,n) for(int (i)=0;(i)<(n);++(i))
#define all(x) (x).begin(),(x).end()

using namespace std;
using ll = long long;

int main() {
    int n; cin >> n;
    vector<int> a(n + 2, 0);
    for(int i = 1; i <= n; ++i) cin >> a[i];

    vector<int> cost(n + 1, 0);
    rep(i, n + 1) cost[i] = abs(a[i + 1] - a[i]);

    ll total = accumulate(all(cost), 0ll); 
    for (int i = 1; i <= n; ++i) {
        cout << (total - cost[i - 1] - cost[i] + abs(a[i - 1] - a[i + 1])) << endl;
    }
}

Measured memory_bytes: 2048
/**
SXR0aXAkI0JwbXptI3FhI3Z3I293bCNqY2IjUG0jMCNicG0jVHFkcXZvLyNCcG0jQW10bjBhY2phcWFicXZvLyNNYm16dml0MSNWdyNhdGN1am16I2tpdiNhbXF9bSNQcXUjVnd6I0F0bW14MSNQcWEjaXptI2l0dCNicHF2b2EjUXYjYnBtI3BtaWRtdmEjaXZsI3d2I21pemJwMSNFcHcjcWEjYnBtem0ja2l2I3F2Ym16a21sbSNRdiNQcWEjeHptYW12a20jbXtrbXhiI0lhI3BtI3htenVxYmJtYnBHI1BtI3N2d2VtYnAjRXBpYiMraXh4bWl6bWJwI2J3I1BxYSNrem1pYmN6bWEjSWEsI0ptbnd6bSN3eiNJbmJteiN3eiNKbXBxdmwjYnBtdTEjVnd6I2FwaXR0I2JwbXwja3d1eGlhYSNJY29wYiN3biNwcWEjc3Z3ZXRtbG9tI017a214YiNpYSNQbSNlcXR0bWJwMSNQcWEjYnB6d3ZtI2x3YnAjbXtibXZsI1dkbXojYnBtI3BtaWRtdmEjSXZsI3d2I21pemJwLyNpdmwjUG0jbm1tdG1icCNWdyNuaWJxb2NtI3F2I29jaXpscXZvI0l2bCN4em1hbXpkcXZvI2JwbXUvI053eiNQbSNxYSNicG0jVXdhYiNQcW9wMSNCcG0jQWN4em11bSMrcXYjb3R3enwsMQ==
*/
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cassert>
 
#define F first
#define S second
#define endl '\n'
#define deb(x) cout<<#x<<' '<<x<<endl;
#define pb push_back
 
/*
#ifdef IZI_KATKA
#define int __int64_t
#else
#define int __int64
#endif
*/
 
const long long MOD = 1e9 + 7;
const long long MAXN = 1e6 + 1;
using namespace std;
 
typedef long long ll;
 
long long readInt() {
    bool minus1 = false;
    long long result = 0;
    char ch;
    ch = getchar();
    while (true) {
        if (ch == '-') break;
        if (ch >= '0' && ch <= '9') break;
        ch = getchar();
    }
    if (ch == '-') minus1 = true; else result = ch-'0';
    while (true) {
        ch = getchar();
        if (ch < '0' || ch > '9') break;
        result = result*10 + (ch - '0');
    }
    if (minus1)
        return -result;
    else
        return result;
}
 
int a[MAXN];
int pref[MAXN];
 
int main() {
	#ifdef IZI_KATKA
	assert(freopen("input", "r", stdin));
    assert(freopen("output", "w", stdout));
    #endif
    int n = readInt();
    for (int i = 1; i <= n; i++) {
    	a[i] = readInt();
	}
	if (a[1]) {
		cout << -1;
		return 0;
	}
    for (int i = 2; i <= n; i++) {
    	if (a[i] > a[i - 1] + 1) {
    		cout << -1;
    		return 0;
    	}
    }
    ll ans = 0;
    for (int i = 2; i <= n; i++) {
    	if (a[i] == a[i - 1] + 1) ans ++;
    	else ans += a[i];
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 4480
#include <stdio.h>
#include <stdint.h>

#define min(x, y) ((x) < (y) ? (x) : (y))
#define max(x, y) ((x) > (y) ? (x) : (y))

int64_t dp[301][301];

int main() {
    char s[301];
    scanf("%s", s);

    int64_t a[302];
    int64_t t = 0, n = 1;
    a[0] = 0;
    for (char* p = s; *p != 0; ++p) {
        if (*p == '0') {
            a[n++] = t;
        } else {
            ++t;
        }
    }
    a[n++] = t;

    int64_t k;
    scanf("%ld", &k);
    k = min(k, a[n - 1]);

    int64_t M = 998244353L;

    int64_t mk = 0;
    dp[0][0] = 1;
    for (int64_t i = 0; i < n - 1; ++i) {
        for (int64_t j = mk; j >= 0; --j) {
            int64_t r = min(k - j, a[i + 1] - a[i]);
            int64_t mc = a[n - 1]  - a[i + 1];
            for (int64_t b = 1; b <= mc + r; ++b) {
                for (int64_t c = max(0L, b - r); c < b && c <= mc; ++c) {
                    int64_t w = j + b - c;
                    dp[w][c] += dp[j][b];
                    if (dp[w][c] >= M) {
                        dp[w][c] -= M;
                    }
                }
            }

            for (int64_t c = 1; c <= a[n - 1] - a[i + 1]; ++c) {
                dp[j][c] += dp[j][c - 1];
                if (dp[j][c] >= M) {
                    dp[j][c] -= M;
                }
            }
        }
        mk = min(k, mk + a[i + 1] - a[i]);
    }

    int64_t ans = 0;
    for (int64_t i = 0; i <= mk; ++i) {
        ans += dp[i][0];
    }

    printf("%ld\n", ans % M);
}


Measured memory_bytes: 2416
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
#include <ctime>
#include <map>
#include <iomanip>
using namespace std;

typedef long long ll;

#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
 
long gcd(long long a, long long b){
	if (a%b==0){
		return b;
	}
	else{
		return gcd(b,a%b);
	}
}
 
long lcm(long long a, long long b){
	return a / gcd(a,b) * b;
}
 
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a < b) { a = b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a > b) { a = b; return 1; } return 0; }
 
const ll INF = 1ll<<60;
const ll MOD = 1000000007;
const double EPS = 1e-10;

int n, m;

int main(){
	int n, m;
	cin >> n >> m;

	if (n == m) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
S = gets.chomp
T = gets.chomp

n = S.size
m = T.size
(0..n-m).reverse_each do |i|
  count = 0
  while S[i+count] == T[count] or S[i+count] == "?"
    count += 1
    break if count == T.size
  end
  
  if count == T.size
    S[i, count] = T
    puts S.gsub("?", "a")
    exit
  end
end
puts "UNRESTORABLE"

Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
#define int long
main(){
  int n;
  double a=0.0;
  cin>>n;
  vector<int> v(n);
  for(auto& i:v)cin>>i;
  sort(v.begin(),v.end());
  for(int i=1;i<n;++i)a=((i>1?a:v[0])+v[i])/2.0;
  cout<<a;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        while (true) {
            String x = scanner.next();

            if (x.equals("0")) break;

            int ret = 0;
            for (int i = 0; i < x.length(); ++i) {
                ret += x.charAt(i) - '0';
            }

            System.out.println(ret);
        }
    }
}


Measured memory_bytes: 26224
#include <stdio.h>

int main(void) {
	int c1,c5,c10,c50,c100,c500,sum,yn = 0;
	scanf("%d%d%d%d%d%d",&c1,&c5,&c10,&c50,&c100,&c500);
	sum = c1 * 1 + c5 * 5 + c10 * 10 + c50 * 50 + c100 * 100 + c500 * 500 ;
	if (sum >= 1000){
		yn = yn + 1 ;
	}
	printf("%d\n",yn);
	return 0;
}
//aoj 0296

Measured memory_bytes: 600
#include <bits/stdc++.h>
#define int long long
#define double long double
using namespace std;
const int MOD = 1000000007;
const int INF = 1e12;
using Graph = vector<vector<int>>;

signed main(){
  int N, K;
  cin >> N >> K;
  vector<int> A(N);
  for( int i = 0; i < N; i++ ) cin >> A[i];

  vector<bool> dp(K+10);
  for( int i = 1; i <= K; i++ ){
    for( int j = 0; j < N; j++ ){
      if( i-A[j] >= 0 && dp[i-A[j]] == 0 ) dp[i] = 1;
    }
  }
  if( dp[K] ) cout << "First" << endl;
  else cout << "Second" << endl;

}

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

int n, fb[200010], fw[200010];
string s;

int main(){
  cin >> n;
  cin >> s;
  fb[0] = fw[n] = 0;
  if (s[0] == '#') fb[0] = 1;
  for (int i=1; i<n; ++i)
    if (s[i] == '#') fb[i] = fb[i-1] + 1;
    else fb[i] = fb[i-1];
  for (int i=n-1; i>=0; --i)
    if (s[i] == '.') fw[i] = fw[i+1] + 1;
    else fw[i] = fw[i+1];
  int res = min(fb[n-1], fw[0]);
  for (int i=0; i<n; ++i)
    res = min(res, fb[i]+fw[i+1]);
  cout << res;
  return 0;
}

Measured memory_bytes: 2180
import java.util.Scanner;



public class Main {
	public static void main(String[] args)
	{
		Scanner scanner = new Scanner(System.in);
		
		for(;;)
		{	
			int m = scanner.nextInt();
			int f = scanner.nextInt();
			int r = scanner.nextInt();
			
			int sum = m + f;
			String result = "";
			if(m==-1 && f==-1 && r==-1)
			{
				break;
			}
			else if(m==-1 || f==-1)
			{
				result = "F";
			}
			else if(sum < 30)
			{
				result = "F";
			}
			else if(30<=sum && sum < 50)
			{
				if(r >= 50)
				{
					result = "C";
				}
				else
				{
					result = "D";
				}
			}
			else if(50<=sum && sum < 65)
			{
				result = "C";
			}
			else if(65<=sum && sum < 80)
			{
				result = "B";
			}
			else {
				result = "A";
			}
			
			System.out.println(result);
		}
	}
}

Measured memory_bytes: 26088
// In god we trust
 
#include <bits/stdc++.h>
#include <chrono>
#include <algorithm>
#include <signal.h>
#include <thread>
 
#define pb push_back
#define fi first
#define se second
#define Vi vector<int>
#define Vb vector<bool>
#define Pi pair<int, int>
#define MP make_pair
#define MT make_tuple
#define Q queue
#define Qi Q<int>
#define INF 1000000000 
#define LINF 1000000000000000000
#define int long long
using namespace std;
using namespace std::chrono;

int c[100010];

signed main(){
  ios_base::sync_with_stdio(false); 
  cin.tie(NULL);

  int n;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++)
    cin >> a[i];
  sort(a, a + n, greater<>());
  int s = 0;
  for (int i = 1; i < n; i++)
    s += a[i/2];

  cout << s << endl;
  
}


Measured memory_bytes: 5172
#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cstring>
#include <cassert>
#include <utility>
#include <iomanip>
#include <chrono>
#include <random>
#include <bitset>

using namespace std;

#define sz(x) (int) x.size()
#define unique(x) x.erase(unique(x.begin(), x.end()), x.end())
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x)) 
#define y1 aksjdaskdjksjfksdjf
#define left kdnvldvoiwejifejg
#define right lkdsjflksdjfdjfk
#define prev asdasfsadjkjsdfjs
#define tm aklsjdasjdasjdkdjjf
#define random_shuffle asdasdd

int n;
int a[2][105];

int main() {

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

  for (int j = n - 1; j >= 0; j--) {
    a[1][j] = a[1][j] + a[1][j + 1];
  }

  int ans = 0;
  int sum = 0;
  for (int i = 0; i < n; i++) {
    sum += a[0][i];
    ans = max(ans, sum + a[1][i]);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(a,b) for(int a=0;a<(b);++a)
#define REP1(i,n) for(int i=1;i<=(n);++i)
#define debug(x) cerr<<#x<<": "<<x<<'\n'
#define all(x) (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n",(x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define isYes(x) printf("%s\n",(x) ? "Yes" : "No")
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
#define INF (1<<29)
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl
#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 X first
#define Y second
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;


template<class T=int>
T in(){T x;cin>>x;return (x);}
template<class T>
void print(T& x){cout<<x<<'\n';}

const int MOD =(int)1e9+7;
const int MAX =510000;
ll fac[MAX],finv[MAX],inv[MAX];
void COMint(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<MAX;i++){
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}
ll COM(int n,int k){
    if(n<k) return 0;
    if(n<0||k<0)return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}
ll gcd(ll a,ll b){
    if(b==0)return a;
    if(a>b){
        swap(a,b);
    }
    return gcd(a,b%a);
}
ll lcm(ll a,ll b){
    ll g;g=gcd(a,b);
    return a*b/g;
}
bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

bool compare_by_a(pair<int, int> a, pair<int, int> b) {
    if(a.first != b.first){
        return a.first < b.first;
    }else{
        return a.second < b.second;
    }
}
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

ll RS(ll N,ll P,ll M){
    if(P==0){
        return 1;
    }else{
        if(P%2==0){
            ll t=RS(N,P/2,M);
            return t*t%M;
        }else{
            return N*RS(N,P-1,M)%M;
        }
    }
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll N,K;
    cin>>N>>K;
    N%=K;
    if(N<=K-N){
        cout<<N<<endl;
    }else{
        cout<<K-N<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
N, X = map(int, input().split())
L = list(map(int, input().split()))
D = [0]
t = 1
while(True):
    if t == N+1:
        break
    D.append(D[t-1]+L[t-1])
    if D[t] > X:
        break
    else:
        t += 1

print(t)


Measured memory_bytes: 2940
#include <stdio.h>

int main(void)
{
	int i, j;
	int m[10];
	int t;
	
	for (i = 0; i < 10; i++){
		scanf("%d", &m[i]);
	}
	
	for (i = 0; i < 10; i++){
		for (j = 10 - 1; j > i; j--){
			if (m[j - 1] < m[j]){
				t = m[j];
				m[j] = m[j - 1];
				m[j - 1] = t;
			}
		}
	}
	
	for (i = 0; i < 3; i++){
		printf("%d\n", m[i]);
	}
	return (0);
}

Measured memory_bytes: 600
#include <iostream>
#include <string>
#include <sstream>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <iomanip>
using namespace std;
typedef long long LL;
LL i,j,k,n,m;
LL mod=1000000007;
string s;

int main() {
  cin >> n >> k;
  long double prob =0.0;
  long double dn = (long double)n;
  for(i=1; i < n+1;++i) {
    long double tmp = (long double)i;
    int exp = 0;
    while(tmp<(long double)k) {
      ++exp;
      tmp = tmp * 2.0;
    }
    prob += pow(0.5, (long double)exp)/dn;
  }
  cout << std::setprecision(11) << prob << endl;
  return 0;
}

Measured memory_bytes: 256
<?php
// Your code here!
fscanf(STDIN, '%s %s', $n, $m);
 
$exp = explode(' ', fgets(STDIN));
$a = [];
for ($i = 0; $i < $n; $i++) {
  $x = intVal($exp[$i]);
  if(!isset($a[$x])){
    $a[$x] = 0;
  }
  $a[$x]++;
}
 
for ($j = 0; $j < $m; $j++) {
  fscanf(STDIN, '%d %d', $num1, $num2);
  if(!isset($a[$num2])){
    $a[$num2] = 0;
  }
  $a[$num2] += $num1;
}

krsort($a);
 
$sum = 0;
$count = $n;
foreach($a as $k => $b){
  $sum += $k * min($b, $count);
  $count -= $b;
  if($count <= 0){
  break;
  }
}
echo $sum;

?>


Measured memory_bytes: 23540
import Data.List

main = do
  n <- readLn
  putStrLn $ show n ++ ": " ++ unwords (fmap show $ solve n)

factors :: Int -> [Int]
factors n = [d | d <- [1..n], n `mod` d == 0]

isPrime :: Int -> Bool
isPrime x = not $ any divisible $ takeWhile notTooBig [2..] where
     divisible y = x `mod`y == 0
     notTooBig y = y*y <= x

primeFactor :: Int -> [Int]
primeFactor 1 = []
primeFactor n = d : primeFactor (n `div` d)
  where d = factors n !! 1

solve :: Int -> [Int]
solve n
  | isPrime n = [n]
  | otherwise = primeFactor n

primeFactor2 :: [Int] -> Int -> [Int]
primeFactor2 res 1 = res
primeFactor2 res n = primeFactor2 (d : res) (n `div` d)
    where d = factors n !! 1

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


/* エイリアス */
#define ll long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vpi vector<pii>
#define vpll vector<pll>
#define endl '\n'

#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define em emplace


/* 関数マクロ */
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep2(i, n, m) for (ll i = n; i <= m; ++i)
#define rep3(i, n, m) for (ll i = n; i >= m; --i)
#define all(v) v.begin(), v.end()
#define si(v) int(v.size())
#define UNIQUE(v) sort(all(v)), v.erase(unique(all(v)),v.end())


/* 定数 */
const ll mod = 1e9 + 7;
const ll infll = (1LL << 62) - 1;
const ll inf = (1LL << 30) - 1;


/* その他 */
template<class S, class T> inline bool chmax(S &a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class S, class T> inline bool chmin(S &a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> using pq = priority_queue<T>;
template<class T> using pqg = priority_queue<T, vector<T>, greater<T>>;

int n;
vector<vi> edge(100001);

vi dijkstra(int start)
{
  vi ret(n, inf);
  ret[start] = 0;
  pqg<pii> que;
  que.em(0, start);

  while (!que.empty()) {
    pii p = que.top(); que.pop();

    int d = p.fi, v = p.se;
    if (ret[v] < d) continue;

    for (auto to : edge[v]) {
      if (ret[to] > d + 1) {
        ret[to] = d + 1;
        que.em(d + 1, to);
      }
    }
  }
  
  return ret;
}

signed main()
{
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);
  
  cin >> n;

  rep(i, n-1) {
    int a, b; cin >> a >> b;
    edge[a-1].eb(b-1);
    edge[b-1].eb(a-1);
  }

  auto black = dijkstra(0);
  auto white = dijkstra(n-1);

  int b = 0, w = 0;
  rep(i, n) {
    if (black[i] <= white[i]) ++b;
    else ++w;
  }
  
  if (b > w) cout << "Fennec" << endl;
  else cout << "Snuke" << endl;
}


Measured memory_bytes: 11520
#!/usr/bin/env python3
import collections
from collections import defaultdict

N, X, Y = list(map(int, input().split()))

skip_d = abs(X - Y)
d_count = defaultdict(lambda: 0)
# d_table = []
for i in range(N):
    # d_list = []
    for j in range(N):
        if i == j:
            d = 0
            d_count[d] += 1
            # d_list.append(d)
            continue
        # Normal
        min_index = min(i, j)
        max_index = max(i, j)

        if min_index <= X - 1 and Y - 1 <= max_index:
            # 両方外にいる
            d = abs(i - j) - skip_d + 1
        elif X - 1 <= min_index and max_index <= Y - 1:
            # 両方中にいる
            d_1 = abs(i - j)
            x2min = abs(min_index - (X - 1))
            max2y = abs((Y - 1) - max_index)
            d_2 = x2min + max2y + 1
            d = min(d_1, d_2)
        elif max_index <= Y - 1:
            # elif min_index <= X - 1 and X - 1 <= max_index < Y - 1:
            # 大きい方が中にいる
            d_1 = abs(i - j)
            max2y = abs((Y - 1) - max_index)
            min2y = abs(min_index - (Y - 1)) - skip_d + 1
            d_2 = max2y + min2y
            d = min(d_1, d_2)
        elif X - 1 <= min_index:
            # elif X - 1 <= min_index < Y - 1 and Y - 1 <= max_index:
            # 小さい方が中にいる
            d_1 = abs(i - j)
            d_2 = (abs(max_index - (X - 1)) - skip_d + 1) + abs((X - 1) - min_index)
            d = min(d_1, d_2)

        # d_list.append(d)
        d_count[d] += 1
    # d_table.append(d_list)

ans_s = []
for k in range(1, N):  # 2 * 10 ** 3
    c = d_count[k]
    c = c // 2
    ans_s.append(str(c))
ans = "\n".join(ans_s)
print(ans)


Measured memory_bytes: 55388
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int k;
   cin>>k;
    string s;
    cin>>s;

   
   int check= s.length();
   if(check<=k)
    cout<<s<<endl;
   else
   {
        for(int i=0;i<k;i++)
    cout<<s[i];
   cout<<"..."<<endl;

   }
   return 0;






}


Measured memory_bytes: 3628
N,K = map(int,input().split())
A = list(map(int,input().split()))
t = 2**40
ans = 0

while t:
  c = sum([(A[n]&t)//t for n in range(N)])
  if K<t or c*2>=N:
    ans+=t*c
  else:
    ans+=t*(N-c)
    K-=t
  t//=2

print(ans)

Measured memory_bytes: 20508
h = int(input())
w = int(input())
n = int(input())
ha = h
wa = w
count = 1
if(h >= w):
    while(n > ha):
        ha += h
        count += 1
    print(count)
else:
    while(n > wa):
        wa += w
        count += 1
    print(count)

Measured memory_bytes: 3064
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <unordered_map> 
#include <unordered_set>
#include <functional>

using namespace std;

typedef pair<long long int, long long int> P;
typedef tuple<int, int, int> T;

long long int INF = 1e18;
long long int MOD = 1e9 + 7;

#define MAX_V 110000
#define MAX_LOG_V 20

vector<int> G[MAX_V];

int parent[MAX_LOG_V][MAX_V]; // 2^k th parent
int depth[MAX_V]; // distance from root
int root = 0;
 
void dfs(int v, int p, int d){
	parent[0][v] = p;
	depth[v] = d;
	for(int i = 0; i < G[v].size(); i++){
		if(G[v][i] != p){
			dfs(G[v][i], v, d + 1);
		}
	}
}
 
void init(int V){
	dfs(root, -1, 0);
	for(int k = 0; k < MAX_LOG_V - 1; k++){
		for(int v = 0; v < V; v++){
			if(parent[k][v] < 0){
				parent[k + 1][v] = -1;
			}else{
				parent[k + 1][v] = parent[k][parent[k][v]];
			}
		}
	}
}

int lca(int u, int v){
	if(depth[u] > depth[v]){
		swap(u, v);
	}
	for(int k = 0; k < MAX_LOG_V; k++){
		if((depth[v] - depth[u]) >> k & 1){
			v = parent[k][v];
		}
	}
	if(u == v){
		return u;
	}
	for(int k = MAX_LOG_V - 1; k >= 0; k--){
		if(parent[k][u] != parent[k][v]){
			u = parent[k][u];
			v = parent[k][v];
		}
	}
	return parent[0][u];
}

int outer = 0;
int memo[55];

int func(int pos, int pre){
	int ret = 0;
	for(int to : G[pos]){
		if(to != pre){
			int p = func(to, pos);
			ret += p;
			if(p == 0){
				outer += 1;
			}
		}
	}
	ret += memo[pos];
	return ret;
}

int main(){
	int N;
	cin >> N;
	for(int i = 0; i < N - 1; i++){
		int a, b;
		cin >> a >> b;
		a -= 1;
		b -= 1;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	init(N);
	int M;
	cin >> M;
	int v1[25], v2[25][2];
	for(int i = 0; i < M; i++){
		int a, b;
		cin >> a >> b;
		a -= 1;
		b -= 1;
		int L = lca(a, b);
		v1[i] = L;
		if(a == L){
			v2[i][0] = v2[i][1] = b;
		}else if(b == L){
			v2[i][0] = v2[i][1] = a;
		}else{
			v2[i][0] = a;
			v2[i][1] = b;
		}
	}
	int cnt[100] = {};
	for(int i = 0; i < (1 << M); i++){
		for(int j = 0; j < N; j++){
			memo[j] = 0;
		}
		int sig = 1;
		for(int j = 0; j < M; j++){
			if(i & (1 << j)){
				sig *= -1;
				memo[v1[j]] -= 1;
				memo[v2[j][0]] += 1;
				if(v2[j][0] != v2[j][1]){
					memo[v1[j]] -= 1;
					memo[v2[j][1]] += 1;
				}
			}
		}
		outer = 0;
		int ret = func(0, -1);
		cnt[outer] += sig;
	}
	long long int ans = 0;
	long long int p2 = 1;
	for(int i = 0; i < 60; i++){
		ans += p2 * cnt[i];
		p2 *= 2;
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;


#define MAXN 100001
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, h;
  cin >> n >> h;
  vector<int> a, b;
  for (int i = 0; i < n; ++i) {
    int A, B;
    cin >> A >> B;
    a.push_back(A);
    b.push_back(B);
  }
  sort(a.rbegin(), a.rend());
  sort(b.rbegin(), b.rend());
  int ans=0, ai=0, bi=0;
  while(h>0) {
    if (bi<n && b[bi]>a[ai]) {
      h -= b[bi++];
      ans++;
    } else {
      ans += (h+a[ai]-1)/a[ai];
      h = 0;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1276
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <ctime>
constexpr int MOD = 1000000007;
constexpr int INF = 2000000000;
using namespace std;

int main() {
	int a, b;
	cin >> a >> b;
	if (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0) {
		cout << "Possible" << endl;
	}
	else {
		cout << "Impossible" << endl;
	}
}

	



Measured memory_bytes: 256
import itertools
n, m = map(int, input().split())
a = set([int(input()) for i in range(m)])
mod = 10 ** 9 + 7
dp = [0] * (n + 1)

dp[0] = 1
dp[1] = 0 if 1 in a else 1

for i in range(2, n + 1):
    if i in a:
        continue
    else:
        dp[i] = (dp[i - 1] + dp[i - 2]) % mod

print(dp[n])


Measured memory_bytes: 13216
#include <cstdio>
#include <string>
#include <cstring>
using namespace std;

int a[110][110];

int main() {
	int n, i, j;
	while (scanf("%d", &n) && n) {
		for (i = 1; i <= n; ++i) {
			for (j = 1; j <= n; ++j) {
				scanf("%d", &a[i][j]);
			}
		}
		bool flag = false;
		for (i = 1; i <= n; ++i) {
			int id = 1;;
			for (j = 1; j <= n; ++j) {
				if (a[i][j] < a[i][id]) {
					id = j;
				}
			}
			for (j = 1; j <= n; ++j) {
				if (a[i][id] < a[j][id]) break;
			}
			if (j <= n) continue;
			printf("%d\n", a[i][id]);
			flag = true;
			break;
		}
		if (flag) continue;
		printf("0\n");
	}
	return 0;
}

Measured memory_bytes: 0
S=input()
T="AKIHABARA"
c=0
t=0
while(True):
    if(len(S)==c):
        if(T[t]=="A"):
            t+=1
        else:
            print("NO")
            exit()
    elif(S[c]==T[t]):
        c+=1
        t+=1
    else:
        if(T[t]=="A"):
            t+=1
        else:
            print("NO")
            exit()
    if(len(S)==c and t==9):
        print("YES")
        exit()
    elif(t==9):
        print("NO")
        exit()

Measured memory_bytes: 38384
def remainder_min(l,r):
    sml = 2*(10**9)**2+1
    _r = min(r,l+2019)
    for i in range(l,_r):
        for j in range(i+1,_r+1):
            num = i * j
            rem = num % 2019
            if rem == 0:
                return 0
            sml = min(sml,rem)
    return sml

if __name__ == '__main__':
    l,r = map(int,raw_input().split())
    print remainder_min(l,r)

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

std::string n;

int main() {

	std::cin >> n;

	if (n[0] == '7' || n[1] == '7' || n[2] == '7')
		std::cout << "Yes" << std::endl;
	else
		std::cout << "No" << std::endl;

	return 0;
}

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

int n, m, ans[102][102], cnt=0, visit=0, tmp=0;
string grid[102];
queue<pair<int, int> >bfs[2];

int main(){
	memset(ans,-1,sizeof ans);
	cin >> n >> m;
	for (int i=0;i<n;i++) cin >> grid[i];
	bfs[0].push({0,0});
	while (visit<n*m){
		int xx=bfs[cnt%2].front().first;
		int yy=bfs[cnt%2].front().second;
		if (grid[xx][yy]=='#') tmp++;
		while (!bfs[cnt%2].empty()){
			int x=bfs[cnt%2].front().first;
			int y=bfs[cnt%2].front().second;
			bfs[cnt%2].pop();
			if (ans[x][y]!=-1) continue;
//			cout << x << " " << y << " " << tmp << "\n";
			ans[x][y]=tmp;
			visit++;
			if (x<n-1){
				if (grid[x+1][y]==grid[x][y]) bfs[cnt%2].push({x+1,y});
				else bfs[(cnt+1)%2].push({x+1,y});
			}
			if (y<m-1){
				if (grid[x][y+1]==grid[x][y]) bfs[cnt%2].push({x,y+1});
				else bfs[(cnt+1)%2].push({x,y+1});
			}
		}
		cnt++;
	}
//	for (int i=0;i<n;i++){
//		for (int j=0;j<m;j++){
//			cout << ans[i][j] << " ";
//		}
//		cout << "\n";
//	}
	cout << ans[n-1][m-1] << "\n"; 
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	if(a==1 && b==0 && c==0 ){
		printf("Close\n");
	}
	if(a==0 && b==1 && c==0){
		printf("Close\n");
	}
	if(a==1 && b==1 && c==0){
		printf("Open\n");
	}
	if(a==0 && b==0 && c==1){
		printf("Open\n");
	}
	if(a==0 && b==0 && c==0){
		printf("Close\n");
	}
	return 0;
}


Measured memory_bytes: 2124
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
using namespace std;
namespace adaptor = boost::adaptors;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
typedef long long ll;

void Main()
{
  string S;
  cin >> S;
  int N = S.size();
  vector<int> a(N);
  rep(i,N){a[i] = S[i]-'0';}
  int compare, temp;
  int tempmin = 1000;
  rep(i,N-2){
  	compare = a[i]*100 + a[i+1]*10 + a[i+2];
    temp = abs(compare-753);
    tempmin = min(tempmin, temp);
  }
  
  cout << tempmin << endl;
  return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}


Measured memory_bytes: 256
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
 
void main()
{
    auto nk = readln.split.to!(int[]);
    auto N = nk[0];
    auto K = nk[1];
    auto HS = readln.split.to!(long[]);
    HS ~= 0;
    long[] hc;

    auto DP = new long[][](N, K+1);
    long solve(int i, int k) {
        if (i == N) return 0;
        if (DP[i][k] == 0) {
            long r = long.max;
            foreach (d; 1..k+2) {
                if (i+d > N) break;
                r = min(r, max(0, HS[i] - HS[i+d]) + solve(i+d, k-d+1));
            }
            DP[i][k] = r;
        }
        return DP[i][k];
    }
    long r = long.max;
    foreach (i; 0..min(N+1, K+1)) {
        r = min(r, solve(i, K-i));
    }
    writeln(r);
}

Measured memory_bytes: 2812
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<limits.h>

#define rep(i,begin,end) for(int i=begin; i<end; i++)
#define revrep(i,begin,end) for(int i=begin; i>end; i--)
#define lld long long int

int main(){
    int h, w;
    int n;
    scanf("%d %d %d", &h, &w, &n);
    int a[n];
    rep(i, 0, n){
        scanf("%d", &a[i]);
    }
    int l=0, r=w, u=-1, d=h;
    int x = 0, y = 0, movement = 0;
    int ans[h][w];
    rep(i, 0, n){
        rep(j, 0, a[i]){
            ans[y][x] = i+1;
            if(movement%4 == 0){
                y++;
                if(y == d){
                    y--;
                    x++;
                    d--;
                    movement++;
                }
            }else if(movement%4 == 1){
                x++;
                if(x == r){
                    x--;
                    y--;
                    r--;
                    movement++;
                }
            }else if(movement%4 == 2){
                y--;
                if(y == u){
                    y++;
                    x--;
                    u++;
                    movement++;
                }
            }else{
                x--;
                if(x == l){
                    x++;
                    y++;
                    l++;
                    movement++;
                }
            }
        }
    }
    rep(i, 0, h){
        rep(j, 0, w){
            printf("%d ", ans[i][j]);
        }
        printf("\n");
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define dup(x,y) (((x)+(y)-1)/(y))
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const double EPS = 1e-10;
const int INF = 1e9;
const ll LINF = 1e15;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

int main() {
	int n;
	cin >> n;
	vector<int> v(n+2);
	v[0] = 0;
	v[n+2-1] = 0;
	rep(i,n) {
		cin >> v[i+1];
	}

	ll sum = 0;
	rep(i,n+1) {
		sum += abs(v[i] - v[i+1]);
	}

	for (int i = 0; i < n; i++) {
		int a = v[i];
		int b = v[i+1];
		int c = v[i+2];
		cout << sum + abs(a-c) - abs(a-b) - abs(b-c) << endl;
	}
}

Measured memory_bytes: 3748
#import<atcoder/all>
#define F int X){return X<b
int n,a,b;int o(int b,F?b:X;}int e(){return-1;}main(){auto&c=std::cin>>n>>a;atcoder::segtree<int,o,e>P(n);for(;b<n;P.set(b++,a))c>>a;for(;c>>n>>a>>b;printf(n<2?P.set(a,b),"":"%d ",n-2?P.max_right(a,[](F;})+1:P.prod(a,b)))a--;}

Measured memory_bytes: 6196
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a,b;
  cin>>a>>b;
  if(a<b)
    cout<<"a < b"<<endl;
  if(a>b)
    cout<<"a > b"<<endl;
  if(a==b)
  cout<<"a == b"<<endl;
}



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

#define rep(i,s,t) for(int i=s,i##end=t;i<=i##end;++i)
#define per(i,s,t) for(int i=t,i##end=s;i>=i##end;--i)
#define repo(i,s,t) for(int i=s,i##end=t;i<i##end;++i)
#define debug(x) cerr<<#x<<" : "<<x<<" "<<__FUNCTION__<<__LINE__<<endl

#define Fuck {puts("-1");exit(0);}

const int MAXN = 1e5 + 5;

int A[MAXN];

int main() {
	int n;
	cin >> n;
	rep (i, 1, n) scanf("%d", &A[i]);
	
	long long k1, k2;
	
	if (A[n] != 2) Fuck;
	
	k1 = k2 = 2;
	
	per (i, 1, n) {
		k1 = (k1 + A[i] - 1) / A[i] * A[i];
		k2 = k2 / A[i] * A[i];
		k2 = k2 + A[i] - 1;
	}
	
	if (k1 > k2) Fuck;
	cout << k1 << " " << k2 << endl;
	return 0;
}

Measured memory_bytes: 640
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please


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


	int OK = 1;
	int N;
	cin >> N;

	rep(i, N) {
		int a;
		cin >> a;
		if (a % 2 == 0) {
			int ikeru = 0;
			if (a % 3 == 0) ikeru = 1;
			if (a % 5 == 0) ikeru = 1;
			if (ikeru == 0) OK = 0;
		}
	}
	co(OK ? "APPROVED" : "DENIED");



	Would you please return 0;
}

Measured memory_bytes: 256
import sys
from collections import deque
input = lambda: sys.stdin.readline().rstrip()


def solve():
    N = int(input())
    A = [[] for _ in range(N)]
    for i in range(N):
        A[i] = list(map(lambda x: int(x) - 1, input().split()))

    # print(A)

    days = 0
    ta = [i for i in range(N)]
    while True:
        ta2 = []
        aset = set()
        for i in ta:
            if len(A[i]) == 0 or i in aset:
                continue
            if i == A[A[i][0]][0]:
                ta2.append(i)
                ta2.append(A[i][0])
                aset |= set([i])
                aset |= set([A[i][0]])
        if len(ta2) > 0:
            for t in ta2:
                A[t].pop(0)
            days += 1
            ta = ta2
        else:
            break

    empty = True
    for i in range(N):
        if len(A[i]) != 0:
            empty = False
            break

    if empty:
        print(days)
    else:
        print(-1)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 35436
S = input()
dic = {}

for  i in range(4):
    if S[i] in dic:
        dic[S[i]] += 1
    else:
        dic[S[i]] = 1
        
if len(dic) == 2 :
    for i in dic :
        if dic[i] != 2:
            print("No")
            break
    else:
        print("Yes")
        
else:
    print('No')
        



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

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

        for (int i = 0; i < S.size(); ++i)
    {
        char S1 = S[S.size() - 1];
        string S2 = S.substr(0, S.size() - 1);
        S = S1 + S2;
        if( S == T ){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

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

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
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; }
typedef long long ll;

const long long INF = 1LL << 60;

int main()
{
    int A, B, X;
    cin >> A >> B >> X;

    if (A <= X && (A + B) >= X) cout << "YES" << endl;
    else cout << "NO" << endl;
    
    return 0;
}

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

const int MOD=1000000007;
struct modint {
  long long val;
  modint(long long val=0) : val((val % MOD + MOD) % MOD){}
  modint operator-() const { return modint(-val); }
  modint& operator+=(const modint a) { if ((val += a.val)     >= MOD) val -= MOD; return *this; }
  modint& operator-=(const modint a) { if ((val += MOD-a.val) >= MOD) val -= MOD; return *this; }
  modint& operator*=(const modint a) { (val *= a.val) %= MOD; return *this; }
  modint operator+(const modint a) const { return (modint)*this += a; }
  modint operator-(const modint a) const { return (modint)*this -= a; }
  modint operator*(const modint a) const { return (modint)*this *= a; }
  modint pow(long long n) const { modint r(1), m(val); while (n > 0) { if (n & 1) {r *= m;} m *= m; n >>= 1; } return r; }
  modint inv() const { return pow(MOD-2); }
  modint& operator/=(const modint a) { return (*this) *= a.inv(); }
  modint operator/(const modint a) const { return (modint)*this /= a; }
  bool operator==(const modint &p) const { return val == p.val; }
  bool operator!=(const modint &p) const { return val != p.val; }
  friend ostream &operator<<(ostream &os, const modint &p) { return os << p.val; }
  friend istream &operator>>(istream &is, modint &a) { long long t; is >> t; a = modint(t); return (is); }
};

vector<bool> sieve_of_eratosthenes(int n) {
  /* O(n log log n) */
  vector<bool> is_prime(n+1, true);
  is_prime[0] = is_prime[1] = false;
  for(int i=2; i<=n; i++)
    if(is_prime[i])
      for(int k=2; k * i <= n; k++)
        is_prime[k*i] = false;
  return is_prime;
}

vector<int> prime_list(int n) {
  /* O(n log log n) */
  auto is_prime = sieve_of_eratosthenes(n);
  vector<int> primes;
  for(int i=0; i<=n; i++)
    if(is_prime[i])
      primes.push_back(i);
  return primes;
}

map<int, int> prime_factorization(int n) {
  /* O(n log log n) */
  auto primes = prime_list((int)ceil(sqrt(n)));
  map<int,int> factors;
  for(auto i : primes) {
    while (n%i==0) {
      factors[i]++;
      n /= i;
    }
  }
  if(n!=1) factors[n]++;
  return factors;
}

int N;
int A[10000];

signed main() {
  cin >> N;
  for(int i=0; i<N; i++) cin >> A[i];

  map<int ,int> primes;

  for(int i=0; i<N; i++) {
    for(auto m : prime_factorization(A[i])) {
      primes[m.first] = max(primes[m.first], m.second);
    }
  }

  modint L = 1;
  for(auto p : primes) {
    L *= modint(p.first).pow(p.second);
  }

  modint ans=0;
  for(int i=0; i<N; i++) {
    ans += L / modint(A[i]); 
  }
  cout << ans << endl;
}


Measured memory_bytes: 768
#include <iostream>
#include <cstdio>
#include <cassert>
#include <cstring>
#include <vector>
#include <valarray>
#include <array>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <complex>
#include <random>

using namespace std;
typedef long long ll;


int main() {
	int n;
	cin >> n;
	ll a, b;
	cin >> a >> b;
	int x[20], y[20], z[20];
	int m;
	cin >> m;
	for (int i = 0; i < m; i++) {
		cin >> x[i] >> y[i] >> z[i];
	}

	int k;
	cin >> k;
	for (int i = m-1; i >= 0; i--) {
		if (x[i] == 0) {
			if (y[i] == k) {
				k = z[i];
			} else if (z[i] == k) { 
				k = y[i];
			}
		} else {
			if (y[i] == k) {
				k = z[i];
			}
		}
	}
	printf("%lld\n", a - b + b*k);
    return 0;
}

Measured memory_bytes: 1148
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
typedef long long ll;
namespace mp = boost::multiprecision;
using Mint = mp::cpp_int;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = int(a); i < int(b); i++)
#define all(v) v.begin(), v.end()
#define uni(v) v.erase(unique(all(v)), v.end())
#define sort_g(v) sort(all(v), greater<int>())
#define dump(x) cerr << #x << ' ' << '=' << ' ' << x << endl

int main() {
    int N, A, B;
    cin >> N >> A >> B;
    cout << ((B - A) % 2 == 0 ? "Alice" : "Borys") << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtTest.ABC_123
{
    class C
    {
        static void Main(string[] args)
        {
            Method(args);
            ReadLine();
        }

        static void Method(string[] args)
        {
          int[] vals=new int[5];
          for(int i=0;i<5;i++){
            int val=ReadInt();
            int val10=(val/10)*10;
            if(val%10>0)val10+=10;
            for(int j=0;j<5;j++){
              if(i==j)vals[j]+=val;
              else vals[j]+=val10;
            }
          }
          Array.Sort(vals);
          WriteLine(vals[0]);
        }

        private static string Read() { return ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 11092
#include<stdio.h>
// 逆行列から
template <typename T>
void extendedEuclidAlgo2(T a,T b,T& x,T &y) {
    T x0,y0,u0,v0;
    T x1,y1,u1,v1;
    T r0,r1,r2;
    T k;
    r0 = a;
    r1 = b;
 
    k = r0 / r1;
    r2 = r0 % r1;
 
    x0 = k;
    y0 = 1;
    u0 = 1;
    v0 = 0;
 
    r0 = r1;
    r1 = r2;
 
    while(r1 != 0) {
        k = r0 / r1;
        r2 = r0 % r1;
 
        x1 = x0*k+y0;
        y1 = x0;
        u1 = u0*k+v0;
        v1 = u0;
 
        r0 = r1;
        r1 = r2;
 
        x0 = x1;
        y0 = y1;
        u0 = u1;
        v0 = v1;
 
    }
 
    T d = x0*v0 - y0*u0;
 
    x = v0/d;
    y = -y0/d;
     
}
 
int main() {
    int a,m;
    int x,y;
    scanf("%d %d",&a,&m);
    extendedEuclidAlgo2(a,m,x,y);
    printf("%d %d\n",x,y);
 
    return 0;
}

Measured memory_bytes: 1024
function Main(input){
    input = input.split("\n");
    var mem = input[0].split(" ").map(Number);
    var arr = input[1].split(" ").map(Number);
    {for(var i=0;i<arr.length;i++){
        arr[i] %= 2;
    }}
    var ans = [BigInt(1),BigInt(0)];
    for(var i=0;i<arr.length;i++){
        if(arr[i]==0){
            ans[0]*=2n;
            ans[1]*=2n;
        }else{
            var tmp = ans[0]+ans[1];
            ans[0] = tmp;
            ans[1] = tmp;
        }
      //  console.log(ans)
    }
    console.log(ans[mem[1]].toString())
}Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());

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

int main(){
    int n, m, c;
    cin >> n >> m >> c;
    int b[m];
    rep(i, m){
        cin >> b[i];
    }
    int a;
    int cnt = 0;
    rep(i, n){
        int sum = 0;
        rep(j, m){
            cin >> a;
            sum += a*b[j];
        }
        sum += c;
        if(sum>0){
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

int main(void)
{
  int a[10000];
  int b;
  int bbb=0;;
  int d;
  int n;
  int i,j;

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

  for (i=0; i<n; i++) {
    b=sqrt(a[i])+1;
    for (j=2; j<=b; j++) {
      if (a[i]==2) {bbb++; break;}
      else if (a[i]%j==0) break;
      else if (j==b) {bbb++; break;}
    }
  }

  printf("%d\n",bbb);

  return 0;
}

Measured memory_bytes: 632