akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define sz(a) (a).size() 
#define all(c) (c).begin(),(c).end()
#define rep(i,n) for(int i=0;i<n;i++)
#define forn(i,n) for(int i=1;i<=n;i++)
#define ford(i,n) for(int i=n;i>=0;i--) 
#define REP(i,a,n) for(int i=a;i<n;i++)
#define foreach(itr,c) for(__typeof((c).begin(),(c).end())itr=c.begin();itr!=c.end();itr++) 
#define fill(a,b) memset(a,b,sizeof(a))
#define re return
#define INF 1e9
#define LINF 1e18
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef vector<int> vi;
typedef vector<pi > vpi; 
int main(){
	int n;
	cin>>n;
	cout<<(1000-n%1000)%1000;
	re 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define ll int64_t
#define _GLIBCXX_DEBUG
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main(){
  int N,M;
  cin >> N>>M;
  vector<vector<int>> G(N);
  for (int i = 0; i < M; ++i) {
        int a, b;
        cin >> a >> b;
        G[a-1].push_back(b-1);
        G[b-1].push_back(a-1);
    }
   // BFS のためのデータ構造
    vector<int> dist(N, -1); // 全頂点を「未訪問」に初期化
    queue<int> que;

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

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

        // v から辿れる頂点をすべて調べる
        for (int nv : G[v]) {
            if (dist[nv] != -1) continue; // すでに発見済みの頂点は探索しない

            // 新たな白色頂点 nv について距離情報を更新してキューに追加する
            dist[nv] = v;
            que.push(nv);
        }
    }
  cout << "Yes" << endl;
  for (int v = 1; v < N; ++v) cout << dist[v]+1 << endl;
}

Measured memory_bytes: 10272
#include <iostream>

using namespace std;

int main()
{
    int N , A , x ;
    cin >> N >> A ;

    x = N / 500 ;
    N = N -(500* x) ;
    if((A - N)>= 0)
    {
        cout << "Yes" << endl;
    }else
    {
        cout << "No" << endl;
    }
    return 0;
}


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

using namespace std;

using ll = long long;

const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

int main () {
  cin.tie(0);
  cout << fixed << setprecision(10);

  while(1) {
    string s; cin >> s;
    if(s == "#") break;
    int sz = s.size();
    int a, b, c, d; cin >> a >> b >> c >> d;
    a--; b--; c--; d--;
    int h = 0, w = 0;
    bool init = true;
    for(int i=0;i<sz;++i) {
      if(init && s[i] == 'b') {
        w++;
      } else if(s[i] == '/') {
        init = false;
        h++;
      } else if(init && s[i] != 'b') {
        w += (int)(s[i] - '0');
      }
    }
    h++;
    
    vector<vector<char>> v(h, vector<char>(w));

    int posh = 0, posw = 0;
    for(int i=0;i<sz;++i) {
      if(s[i] == 'b') {
        v[posh][posw] = 'b';
        posw++;
      } else if(s[i] == '/') {
        posw = 0;
        posh++;
      } else {
        int cnt = (int)(s[i] - '0');
        while(cnt > 0) {
          v[posh][posw] = '.';
          posw++;
          cnt--;
        }
      }
    }

    v[a][b] = '.';
    v[c][d] = 'b';

    for(int i=0;i<h;++i) {
      int cnt = 0;
      for(int j=0;j<w;++j) {
        if(v[i][j] == 'b') {
          if(cnt != 0) cout << cnt;
          cnt = 0;
          cout << "b";
        } else {
          cnt++;
        }
      }
      if(cnt != 0) cout << cnt;
      cnt = 0;
      if(i != h-1) cout << '/';
    }
    cout << endl;
  }
}



Measured memory_bytes: 3100
#include <stdio.h>

int H, W, dp[2][10946][2][2], bits[10946], conv[1 << 19], maxbits;

char M[20][21];

int main()
{
	scanf("%d", &H);
	scanf("%d", &W);

	for (int i = 0; i < H; i++) scanf("%s", M[i]);

	if (M[0][0] == 'J' || M[0][0] == '?') dp[0][0][0][0] += 1;
	if (M[0][0] == 'O' || M[0][0] == '?') dp[0][0][1][0] += 1;
	if (M[0][0] == 'I' || M[0][0] == '?') dp[0][0][1][0] += 1;

	int maxbit = 1 << (W - 1);

	for (int i = 0; i < maxbit; i++)
	{
		bool ok = true;

		for (int j = 0; j < W - 2; j++)
		{
			if ((i & (1 << j)) && (i & (1 << (j + 1))))
			{
				ok = false; break;
			}
		}

		if (ok)
		{
			conv[i] = maxbits; bits[maxbits++] = i;
		}
	}

	for (int i = 0; i < H * W - 1; i++)
	{
		int s = i % 2;
		int t = (i + 1) % 2;

		for (int j = 0; j < maxbits; j++)
		{
			dp[t][j][0][0] = 0;
			dp[t][j][0][1] = 0;
			dp[t][j][1][0] = 0;
			dp[t][j][1][1] = 0;
		}

		char nowc = M[i / W][i % W];
		char nxtc = M[(i + 1) / W][(i + 1) % W];

		for (int j = 0; j < maxbits; j++)
		{
			int nxt = (bits[j] << 1) & (maxbit - 1);

			int sum0 = (dp[s][j][0][0] + dp[s][j][1][0]) % 100000;
			int sum1 = (dp[s][j][0][1] + dp[s][j][1][1]) % 100000;

			if (nxtc == 'J' || nxtc == '?')
			{
				dp[t][conv[nxt]][0][0] += sum0;
				dp[t][conv[nxt]][0][1] += sum1;
			}

			if (nxtc == 'O' || nxtc == '?')
			{
				if ((nowc == 'J' || nowc == '?') && i % W != W - 1)
				{
					dp[t][conv[nxt + 1]][1][0] += dp[s][j][0][0];
					dp[t][conv[nxt + 1]][1][1] += dp[s][j][0][1];

					dp[t][conv[nxt + 1]][1][0] %= 100000;
					dp[t][conv[nxt + 1]][1][1] %= 100000;

					dp[t][conv[nxt]][1][0] += dp[s][j][1][0];
					dp[t][conv[nxt]][1][1] += dp[s][j][1][1];
				}
				else
				{
					dp[t][conv[nxt]][1][0] += sum0;
					dp[t][conv[nxt]][1][1] += sum1;
				}
			}

			if (nxtc == 'I' || nxtc == '?')
			{
				if (bits[j] & (1 << (W - 2)))
				{
					dp[t][conv[nxt]][1][1] += sum0;
				}
				else
				{
					dp[t][conv[nxt]][1][0] += sum0;
				}

				dp[t][conv[nxt]][1][1] += sum1;
			}

			dp[t][conv[nxt]][1][0] %= 100000;
			dp[t][conv[nxt]][1][1] %= 100000;
		}
	}

	int ret = 0;

	int last = (H * W + 1) % 2;

	for (int i = 0; i < maxbits; i++)
	{
		ret += dp[last][i][0][1];
		ret += dp[last][i][1][1];

		ret %= 100000;
	}

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

	return 0;
}

Measured memory_bytes: 3416
#include<iostream>
#include<cmath>
#include<numeric>
#include<functional>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<iomanip>
#include<queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<n;i++)
#define ll long long
#define INF 2147483647
using namespace std;
using Graph=vector<vector<int>>;

int main(){
  ll n,k; cin>>n>>k; ll a[n];
  rep(i,n){
    cin>>a[i];
  }
  sort(a,a+n);
  ll mod=1000000007;
  ll inv[n+1],hogeCkminus1[n]; inv[1]=1;
  for(int i=2;i<n+1;i++){
    inv[i]=mod-inv[mod%i]*(mod/i)%mod;
  }
  for(int i=0;i<k-1;i++){
    hogeCkminus1[i]=0;
  }
  hogeCkminus1[k-1]=1;
  for(int i=k;i<n;i++){
    hogeCkminus1[i]=(hogeCkminus1[i-1]*i)%mod;
    hogeCkminus1[i]=(hogeCkminus1[i]*inv[i-k+1])%mod;
  }
  // rep(i,n){cout<<hogeCkminus1[i]<<"\n";}
  ll ans=0;
  for(int i=0;i<n;i++){
    ans+=(a[i]*(hogeCkminus1[i]-hogeCkminus1[n-1-i]))%mod;
    ans%=mod;
  }
  cout<<ans;
}


Measured memory_bytes: 5888
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define rrep(i, a, b) for (int i = a; i >= (b); i--)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
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;
}
void hr() {
   cerr << "--------------" << endl;
}
const int INF = 1001001001;
const int MOD = 1000000007;

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

   int N, a, b;
   cin >> N >> a >> b;
   ll ans = 0;
   rep(num, 1, N + 1) {
      ll sum = 0;
      int x = num;
      while (x) {
         sum += x % 10;
         x /= 10;
      }
      if (sum >= a && sum <= b) ans += num;
   }
   cout << ans << endl;
   return 0;
}

Measured memory_bytes: 256
"""
int #整数
float #小数

#for
for name in fruits: #fruitの頭から操作
    print(name)
    
#リスト
list0 = [] #リスト生成
list0 = [1,2,3,4] #初期化
list0 = [0]*10 #[0,0,0,0,0,0,0,0,0,0]
list1= [i for i in range(10)] #>>> [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
list1 = list(map(int, input().split()))　# 複数の入力をリストに入れる
number=[int(input()) for i in range(int(input()))] #複数行の入力をリストに
list1 = list1 + [6, 7, 8] #リストの追加
list2.append(34) #リストの追加　最後に（）内が足される
list.insert(3,10) #リストの追加　任意の位置（追加したい位置,追加したい値）
len(list4) #リストの要素数
max(sa) #list saの最小値
list5.count(2) #リスト(文字列も可）内の2の数
list1.sort() #並び替え小さい順
list1.sort(reverse=True)  #並び替え大きい順
set(list1) #list1内の重複している要素を削除し、小さい順に並べる
sum([2,3,   ,3]) #リストの合計

abs(a) #aの絶対値
max(a,b) min(a,b) #最大値　最小値
text1 = text1.replace("34","test") #text1内の"34"を"test"に書き換える(文字列内の文字を入れ替える)

exit(0) #強制終了
"""
K, S = map(int, input().split())
count = 0
for i in range(K + 1):
    for j in range(K + 1):
        Z=S-i-j
        if 0<=Z<=K:
            count += 1

print(count)


Measured memory_bytes: 9104
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
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;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}

int main() {
    int N, K;
    cin >> N >> K;
    int num = 1;
    for(int i = 0; i < N; i++) {
        if(num * 2 < num + K) {
            num *= 2;
        } else {
            num += K;
        }
    }
    cout << num << endl;
}

Measured memory_bytes: 256
sa = str(input())
sb = str(input())
sc = str(input())

follower = 'a'
sa_count = 0
sb_count = 0
sc_count = 0

for i in range(len(sa)+len(sb)+len(sc)):
    if follower == 'a':
        if sa_count == len(sa):
            ans = 'A'
            break
        follower = sa[sa_count]
        sa_count += 1
    elif follower == 'b':
        if sb_count == len(sb):
            ans = 'B'
            break
        follower = sb[sb_count]
        sb_count += 1
    elif follower == 'c':
        if sc_count == len(sc):
            ans = 'C'
            break
        follower = sc[sc_count]
        sc_count += 1
print(ans)

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


int main() {
  
  int N,M;
  cin >> N >> M;
 
  vector<pair<int,int>> vec(N);
  

  for(int i = 0;i < N;i++) {
      int a,b;
      cin >> a >> b;
      pair<int,int> q = make_pair(a,b);
      vec.at(i) = q;
  }

  sort(vec.begin(),vec.end());


  long long ans = 0;
  priority_queue<int> pq;
  int now = 0;

  for(int i = 1;i <= M;i++) {

    
    
    while(now < N && vec.at(now).first <= i) {
      pq.push(vec.at(now).second);
      now++;
    }

    if(!pq.empty()) {
      long long p = pq.top();
      pq.pop();

      ans += p;
    }
    

  }

  cout << ans << endl;


  }


Measured memory_bytes: 1660
#include <iostream>
#include <string.h>
#include <cstring>
#include <cstdio>
#include <vector>
#include <set>
#include <math.h>
#include <algorithm>
using namespace std;
const int maxn=1005;

int change(char a){
    if(a=='M') return 1;
    else if(a=='A') return 2;
    else if(a=='R') return 3;
    else if(a=='C') return 4;
    else if(a=='H') return 5;
}
long long  a[6]={0};
long long ans;
int main() {
    int n,cnt=0;
    string s;
    cin>>n;
    while(n--){
        cin>>s;
        if(s[0]=='M'||s[0]=='A'||s[0]=='R'||s[0]=='C'||s[0]=='H'){
            a[change(s[0])]++;
        }
    }
   ans=a[1]*a[2]*a[3]+a[1]*a[2]*a[4]+a[1]*a[2]*a[5]+a[2]*a[3]*a[4]+a[2]*a[3]*a[5]+a[1]*a[3]*a[4]+a[1]*a[3]*a[5]+a[2]*a[4]*a[5]+a[3]*a[4]*a[5]+a[1]*a[4]*a[5];
   cout<<ans;
   return 0;
}

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

int main()
{
    int i,ani,lag;
    scanf("%d %d",&ani,&lag);
    for(i=0;i<=ani;i++)
    {
        if((i*2+(ani-i)*4)==lag)
        {
            printf("Yes");
            return 0;
        }
    }
    printf("No");
    return 0;
}


Measured memory_bytes: 1704
#include <iostream>
#include <vector>
#include <tuple>
#include <algorithm>
using namespace std;

int main() {
  int n;
  cin >> n;
  vector<tuple<int, int, int>> point(n + 1); // t, x, y;
  point[0] = make_tuple(0, 0, 0);
  int t, x, y;
  int i;
  for (i = 0; i < n; i++) {
    cin >> t >> x >> y;
    point[i + 1] = make_tuple(t, x, y);
  }
  int diff_t, diff_x, diff_y, manhattan;
  for (i = 1; i < n + 1; i++) {
    diff_t = get<0>(point[i]) - get<0>(point[i - 1]);
    diff_x = abs(get<1>(point[i]) - get<1>(point[i - 1]));
    diff_y = abs(get<2>(point[i]) - get<2>(point[i - 1]));
    manhattan = diff_x + diff_y;
    if (!(diff_t >= manhattan && (diff_t - manhattan) % 2 == 0)) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 1408
#include<iostream>
using namespace std;
int main()
{
int a, b;
char op;
while(true)
	{
		cin >> a >> op >>b;
		if ( op == '?' )break;
		else if ( op == '+' )
			{
				a = a + b;
				cout << a << endl;
			}
		else if ( op == '-' )
			{
				a = a - b;
				cout << a << endl;
			}
		else if ( op == '*' )
			{
				a = a * b;
				cout << a << endl;
			}
		else if ( op == '/' )
			{
				a = a / b;
				cout << a <<endl;
			}
	}
	return 0;
}

Measured memory_bytes: 1160
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<int,int> PP;

/*
    freopen("input","r",stdin);
    freopen("output","w",stdout);
*/

ll A[200010], B[200010];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int N;
    cin >> N;
    ll sol = 0;
    bool ok = 1;
    for (int i = 0;i < N;i++) cin >> A[i] >> B[i];
    ll mi = 1E9;
    for (int i = 0;i < N;i++) {
    	if (A[i] != B[i]) ok = 0;
    	sol += A[i] + B[i];
    	if (A[i] > B[i]) mi = min(mi, B[i]);
    }
    sol -= mi * 2;
    if (ok) cout << 0 << endl;
    else cout << sol / 2 << endl;
    return 0;
}

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

using namespace std;

int main(void) {
    int N, K;
    cin >> N >> K;

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

    sort(p.begin(),p.end());

    int result = 0;
    for(int i = 0;i<K;i++) {
        result += p[i];
    }

    cout << result << endl;

    return 0;


}

Measured memory_bytes: 3636
n=int(input())
lst=list(int(input()) for _ in range(n))
lst_sum=sum(lst)
lst_sort=sorted(lst)
ans=0
if lst_sum%10!=0:
    print(lst_sum)
else:
    ans=lst_sum
    for i in range(n):
        if (lst_sort[i] % 10) !=0:
            ans-=lst_sort[i]
            if ans%10!=0:
                print(ans)
                break
    else:
        print(0)

Measured memory_bytes: 3064
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int compare_int(const void *a, const void *b)
{
//    return *(int*)a - *(int*)b;
    return *(long long*)a - *(long long*)b;
}
//  qsort(A, b, sizeof(int), compare_int);

int main()
{
 
  int a, b, c, d, e, X, Y;
  //  double  c;
//  long long  A[100003]={};
  int  B[100003]={};
  int  C[100003]={};

  int  flag[103]={};

//  long long  a, b, c, d, X, Y;
char s[101][101]={};
  long long JPY;
  double BTC;
char t[101][101]={};
//  int N, M;
//  int A[1000000001]={};
//  long long  C[101]={};
  int i,j,k;
//  int flag=0;
  double tmp=0;
//  int min=1000000;
  long long min=100000001;
  int len=0;
  int cnt=0;
  int num=0;
  double ans=0.0;
  int max=0;
  int sum=0;
//  char alp[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};

  //  a=0;
//  scanf("%lld %lld", &a, &b);
  scanf("%d", &a);
  for(i=0;i<a;i++){
    scanf("%s", s[i]);
    scanf("%s", t[i]);
//    printf("%s\n ",t[i]);
  }
  for(i=0;i<a;i++){
//    printf("loop:%d ",i);
//    printf(" %s\n ",t[i]);
    if(strcmp("JPY",t[i]) == 0){
      tmp = atoi(s[i]);
    }
    if(strcmp("BTC",t[i]) == 0){
      tmp = atof(s[i]);
      tmp = tmp * 380000;
    }
    ans = ans +tmp;

  } 
    printf("%lf\n",ans);
  //  //  if(flag==0)   printf("TLE\n");
//    if(max < cnt - max)  printf("Yes\n");
//    else  printf("No\n");
  
return 0;
}


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

//#define int long long
#define ll long long
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{   
    gearup;
    ll n,k; cin >> n >> k;
    vl l(n);
    rep(i,n) cin >> l[i];
    sort(all(l),greater<ll>());
    ll res = 0;
    rep(i,k){
        res += l[i];
    }
    cout << res << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#define mymalloc(p, n) {p = malloc((n)*sizeof(*p)); if((p) == NULL){printf("not enough memory.\n"); exit(1);}}

void trace(int A[], int n){
  int i;
  for ( i = 0; i < n; i++ ){
    if ( i > 0 ) printf(" ");
    printf("%d", A[i]);
  }
  printf("\n");
}

int main() {
  int n;
  int *A;
  int i, j, k, key;

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

trace(A, n);

  for(i = 1; i < n; i++) {
    key = A[i];
    j = i;
    while(key < A[j-1] && j > 0) {
      A[j] = A[j-1];
      A[j-1] = key;
      j--;
    }
trace(A, n);
  }

  return 0;
}

Measured memory_bytes: 604
L = input()
mod = 10**9 + 7

x = len(L)
L = int(L, 2)
DP1 = [0] * (x+1)  # sure under L
DP2 = [0] * (x+1)  # possible under L
DP1[1] = 1
DP2[1] = 2
for i in range(2, x+1):
    if (L >> (x-i)) & 1:
        DP1[i] = (DP1[i-1] * 3 + DP2[i-1]) % mod
        DP2[i] = DP2[i-1] * 2 % mod

    else:
        DP1[i] = DP1[i-1] * 3 % mod
        DP2[i] = DP2[i-1]
ans = (DP1[x] + DP2[x]) % mod
print(ans)

Measured memory_bytes: 11124
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N; cin >> N;
  N *= 2;
  vector<int> V(N);
  for(auto&&e:V){
    cin >> e;
  }
  sort(V.begin(), V.end());
  int sum = 0;
  for(int i = 0; i < N; i += 2){
    sum += V[i];
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
char s[110];
int main(){
	int k,n,i;
	scanf("%d%s",&k,s+1);
	n=strlen(s+1);
	if(n<=k)printf("%s\n",s+1);
	else{
		for(i=1;i<=k;i++)printf("%c",s[i]);
		printf("...\n");
	}
}

Measured memory_bytes: 1648
while True :
    n = int(input())
    if n == 0 :
        break
    max_d = 0
    max_p = 0
    for i in range(n) :
        p, a, b = map(int, input().split())
        if max_d < (a + b) :
            max_d = a + b
            max_p = p
    print(max_p, max_d)
    


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

const int INF = 1001001001;
int d[100005];

int n;
vector<vector<int>> to(100005);
vector<vector<int>> length(100005);
stack<int> q;
void dfs(int c_v){
  for(int i=0;i<to[c_v].size();i++){
    int n_v = to[c_v][i];
    int l = length[c_v][i];
    if (d[n_v] != INF) continue;
    q.push(to[c_v][i]);
    d[n_v] = (d[c_v]+l)%2;
    dfs(n_v);
  }
  q.pop();
}

int main() {
  cin >> n;
  rep(i,n-1) {
    int u,v,w;
    cin >> u >> v >> w;
    --u; --v;
    to[u].push_back(v);
    to[v].push_back(u);
    length[u].push_back(w);
    length[v].push_back(w);
  }
  // cout << "ok" << endl;
  rep(i,n) d[i] = INF;
  q.push(0);
  d[0] = 0;
  dfs(0);
  rep(i,n)cout << d[i] << endl;
  return 0;
}


Measured memory_bytes: 14592
#include <cstdio>

typedef long long LL;
const int Mod = 1000000007;
const int MN = 2005, MS = 4000005;

inline int qPow(int b, int e) {
	int a = 1;
	for (; e; e >>= 1, b = (LL)b * b % Mod)
		if (e & 1) a = (LL)a * b % Mod;
	return a;
}

int Fac[MS], iFac[MS];
inline void Init(int N) {
	Fac[0] = 1;
	for (int i = 1; i <= N; ++i) Fac[i] = (LL)Fac[i - 1] * i % Mod;
	iFac[N] = qPow(Fac[N], Mod - 2);
	for (int i = N; i >= 1; --i) iFac[i - 1] = (LL)iFac[i] * i % Mod;
}
inline int Binom(int N, int M) {
	return (LL)Fac[N] * iFac[M] % Mod * iFac[N - M] % Mod;
}

int N, K;
int f[MN][MN];

int main() {
	scanf("%d%d", &N, &K);
	if (K == 1 || N == 1) return puts("1"), 0;
	Init(N * K);
	f[0][0] = 1;
	for (int j = 1; j <= N; ++j) f[0][j] = (LL)f[0][j - 1] * Binom(j * (K - 1) - 1, K - 2) % Mod;
	for (int i = 1; i <= N; ++i) {
		f[i][i] = f[i - 1][i];
		for (int j = i + 1; j <= N; ++j)
			f[i][j] = (f[i - 1][j] + (LL)f[i][j - 1] * Binom(i + j * (K - 1) - 1, K - 2)) % Mod;
	}
	printf("%lld\n", (LL)f[N][N] * Fac[N] % Mod);
	return 0;
}

Measured memory_bytes: 47104
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		//		new Main().solveA();
		//		new Main().solveB();
		new Main().solveC();
		// new Main().solveD();
	}

	private void solveA() {
		Scanner scanner = null;
		int numX = 0;
		int numA = 0;
		int numB = 0;

		try {
			scanner = new Scanner(System.in);
			numX = scanner.nextInt();
			numA = scanner.nextInt();
			numB = scanner.nextInt();

			System.out.println((numX - numA) % numB);

			System.out.println("");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveB() {
		Scanner scanner = null;
		int numA = 0;
		int numB = 0;
		int numC = 0;
		int numX = 0;

		try {
			scanner = new Scanner(System.in);
			numA = scanner.nextInt();
			numB = scanner.nextInt();
			numC = scanner.nextInt();
			numX = scanner.nextInt();

			int res = 0;
			for (int i = 0; i <= numA; i++) {
				for (int j = 0; j <= numB; j++) {
					for (int k = 0; k <= numC; k++) {
						if (i * 500 + j * 100 + k * 50 == numX) {
							res++;
						}
					}
				}
			}

			System.out.println(res);

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private int getAme(int[][] wk, int x, int y) {
		int res = 0;

		if (x >= 2 || y >= wk[0].length) {
			return 0;
		}

		int val1 = getAme(wk, x + 1, y) + wk[x][y];
		int val2 = getAme(wk, x, y + 1) + wk[x][y];

		res = Math.max(val1, val2);
		return res;
	}

	private void solveC() {
		Scanner scanner = null;
		int numN = 0;

		try {
			scanner = new Scanner(System.in);
			numN = scanner.nextInt();

			int[][] wk = new int[2][numN];

			for (int i = 0; i < wk.length; i++) {
				for (int j = 0; j < numN; j++) {
					wk[i][j] = scanner.nextInt();
				}
			}

			System.out.println(getAme(wk, 0, 0));

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveD() {
		Scanner scanner = null;
		int numN = 0;
		int numK = 0;
		int numS = 0;

		try {
			scanner = new Scanner(System.in);
			numN = scanner.nextInt();

			System.out.println("");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}
}

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

using namespace std;

int main()
{
	int h, w;
	cin >> h >> w;
	string a[500];
	for (int i = 0; i < h; i++)
		cin >> a[i];
	for (int i = 0; i < h; i++)
	{
		if (i % 2 == 0)
		{
			for (int j = 0; j < w - 1; j++)
				cout << "#";
			if (a[i][w] == '#')
				cout << "#" << endl;
			else
				cout << "." << endl;
		}
		else
		{
			cout << "#";
			for (int j = 1; j < w; j++)
				if (a[i][j] == '#')
					cout << "#";
				else
					cout << ".";
			cout << endl;
		}
	}
	cout << endl;
	for (int i = 0; i < h; i++)
	{
		if (i % 2 == 0)
		{
			for (int j = 0; j < w - 1; j++)
				if (a[i][j] == '#')
					cout << "#";
				else
					cout << ".";
			cout << "#" << endl;
		}
		else
		{
			if (a[i][0] == '#')
				cout << "#";
			else
				cout << ".";
			for (int i = 1; i < w; i++)
				cout << "#";
			cout << endl;
		}
	}

	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>

#define CK(N,A,B) (A<=N&&N<B)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define RREP(i,a,b) for(int i=(b-1);a<=i;i--)
#define F first
#define S second
#define ll long long

const int INF = 1e9;
const long long  LLINF = 1e18;

using namespace std;

int N;
long long ans = 0;

int main(){
  cin>>N;
  REP(i,0,N){
    int l, r;
    cin>>l>>r;
    ans += r -l + 1;
  }

  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int h1 = sc.nextInt();
    int m1 = sc.nextInt();
    int h2 = sc.nextInt();
    int m2 = sc.nextInt();
    int k = sc.nextInt();
    
   	int time = m2 + (h2-h1)*60 - m1 - k;
    
    System.out.println(time);
  }
}


Measured memory_bytes: 35664
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define pb push_back
#define all(v) v.begin(),v.end()
#define fi first
#define se second
#define bigger (char)toupper
#define smaller (char)tolower
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<string> vs;
typedef vector<char> vc;
typedef long long ll;
typedef unsigned long long ull;

int main() {
    int N;
    cin>>N;
    vi a(3*N);
    rep(i,3*N) cin>>a[i];
    sort(a.begin(),a.end(),greater<int>());
    ll counter=0;
    for(int i=1; i<=N; i++) {
        counter+=a[i*2-1];
    }
    cout<<counter<<endl;
}

Measured memory_bytes: 1408
//Remaining Balls

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,x,y) for(ll i=x;i<y;i++)
#define irep(i,a) for(auto i = a.begin(); i != a.end(); ++i)
#define nvarep(n,a) ll n;cin>>n;vector<ll>a(n);rep(i,0,n)cin>>a[i]
#define nxvarep(n,x,a) ll n,x;cin>>n>>x;vector<ll>a(n);rep(i,0,n)cin>>a[i]
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a/__gcd(a, b)*b)
#define range(a) (a).begin(),(a).end() 
#define pb push_back
#define mp make_pair
#define nnn "\n"
#define spa " "
#define cout15(a) printf("%.15f\n",a)
template<class T>inline bool chmin(T& a,T b,bool f){
if(f==1){if(a>b){a=b;return true;}return false;}
else if(f==0){if(a<b){a=b;return true;}return false;}return false;}
typedef pair<ll,string> p;
const int inf = 2147483647;//2*10^9
const ll INF = 9223372036854775807;//9*10^18

int main (){
    string s,t,u;cin>>s>>t;
    int a,b;cin>>a>>b>>u;
    if(u==s){
        cout<<a-1<<spa<<b<<nnn;
        return 0;
    }else{
        cout<<a<<spa<<b-1<<nnn;
        return 0;
    }
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
const ll mod=1000000007;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
const int MAX_V = 110;
struct Flow{
//辺の構造体　
struct edge{
    //行き先、容量、逆辺の場所
    ll to,cap,rev;
};
//グラフの隣接リスト
V<edge> G[MAX_V];
//DFSで調べた頂点を記録
bool used[MAX_V];
//辺の情報を代入する関数
void add_edge(ll from,ll to,ll cap){
    G[from].push_back((edge){to,cap,(ll)G[to].size()});
    G[to].push_back((edge){from,0,(ll)G[from].size()-1});
}
//増加パスをDFSで探す
ll dfs(ll v,ll t,ll f){
    if(v==t)return f;
    used[v]=true;
    for(int i=0;i<G[v].size();i++){
        edge &e=G[v][i]; //辺の容量を更新するためのアドレス
        if(!used[e.to]&&e.cap>0){
            ll d=dfs(e.to,t,min<ll>(f,e.cap));
            if(d>0){
                e.cap-=d;//使った分減らす
                G[e.to][e.rev].cap+=d;//使った分逆辺の容量を増やす
                return d;
            }
        }
    }
    return 0;
}
//sからtへの最大流を求める
ll max_flow(ll s,ll t){
   ll flow=0;
   while(1){
       for(int i=0;i<MAX_V;i++)used[i]=false;
       ll f=dfs(s,t,10e9);
       if(f==0)return flow;
       flow+=f;
   }
}
};
int main(){
int v,e;cin>>v>>e;
Flow mf;
for(int i=0;i<e;i++){
    int a,b,c;
    cin>>a>>b>>c;
    mf.add_edge(a,b,c);
}
  cout<<mf.max_flow(0,v-1)<<endl;
}



Measured memory_bytes: 3244
#include <iostream>
#include <functional>
#include <algorithm>
#include <vector>
#include <utility>
using namespace std;

typedef pair<int, int> bou;
int main(){
  int n,m,a;
  while(cin >> n >> m >> a && n|m|a!=0){

    vector<pair<int, bou> > yokobou; 
    int high=0;
    int h,p,q;
    //while(cin>>h>>p>>q&&h|p|q!=0){
    for(int i=0;i<m;i++){
      cin >> h >> p >> q;
      if(high<h) high=h;
      yokobou.push_back(make_pair(h, bou(p, q)));
    }
    // sort
    sort(yokobou.begin(),yokobou.end(),greater<pair<int, bou> >());

    /* for_each(yokobou.begin(), yokobou.end(), [](pair <int, pair <int, int> > elm){
       cout << elm.first << " " << elm.second.first << " " << elm.second.second << endl;
       });*/

    // 今いる縦棒 今いる高さ
    int now = a;
    for(int h=1000;h>0;h--){
      for(int i=0;i<m;i++){
        if(h!=yokobou[i].first) continue;;
        if(yokobou[i].second.first==now){
          now = yokobou[i].second.second;
          /*        yokobou.erase(yokobou.begin()+i);
                    m--;*/
        }
        else if(yokobou[i].second.second==now){
          now = yokobou[i].second.first;
          //yokobou.erase(yokobou.begin()+i);
          //m--;
        }
      }
    }
    cout << now << endl;
  }
  return 0;
  }

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

//**************************************************************************************************************************************************************************
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
//**************************************************************************************************************************************************************************
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define mod 1000000007
#define pi acos(-1.0)
#define eps 1e-9
#define inf 1e18
#define sz(x) (int)((x).size())
#define gcd(a, b) __gcd(a, b)
#define LCM(x, y) (((x) / __gcd((x), (y))) * (y))
#define mem(x, n) memset(x, n, sizeof(x))
#define setbits(x) __builtin_popcountll(x)
#define zrobits(x) __builtin_ctzll(x)
#define ps(x, y) fixed << setprecision(y) << x
#define FastIO               \
    ios::sync_with_stdio(0); \
    cin.tie(0);              \
    cout.tie(0);
//**************************************************************************************************************************************************************************

void c_p_c()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

int main(int argc, char const *argv[])
{
    c_p_c();
    FastIO;
    ll a, b, c, k, ans;
    cin >> a >> b >> c >> k;
    if (k <= a)
    {
        cout << k << endl;
    }
    else if ((a + b) >= k)
    {
        if(a>=k)
        cout << k << endl;
        else 
        cout<<a<<endl;

    }
    else if ((a + b) < k)
    {
        ans = k-(a+b);
        if (c >= ans)
            cout << a - ans << endl;
        else
            cout <<a-c<< endl;
    }
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define REPD(i,a,b) for (int i=(a);i<(b);i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef set<int> si;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<int, int> pi;
typedef queue<int> qi;
typedef queue<pi> qpi;
typedef pair<ll, ll> pll;
typedef queue<pll> qpll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
const int mod = 1000000007;
const int INF = 1001001001;
// 小数点　<< fixed << setprecision(0) <<
// sort降順　sort(ALL(),greater<int>());
// 円周率　M_PI
// 文字判定　isupper islower
// 順列　do {} while(next_permutation(ALL(X)));
// 最大値　LLONG_MAX
// a内でx以上　auto iter = lower_bound(ALL(a), x);
// a内でxより大きい　auto iter = upper_bound(ALL(a), x);
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
struct edge {
    int from; //出発点
    int to;   //到達点
    int cost; //移動コスト
};
typedef struct edge se;
typedef vector<edge> ve;
unsigned euclidean_gcd(unsigned a, unsigned b) {
  if(a < b) return euclidean_gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

int main() {
  int a,b,c,k;
  cin >> a >> b >> c >> k;
  int ans=0;
  if(k<=a) {
    ans=k;
  } else if(a<k&&k<=a+b) {
    ans=a;
  } else {
    ans=a-(k-a-b);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
typedef long long lint;

#define PI acos(-1)
#define INF64 1LL << 60
#define INF32 1 << 29
#define all(a) (a).begin(), (a).end()

using namespace std;

void execute()
{

	vector<int> a(3, 0);
	vector<int> b(3, 0);

	vector<vector<int>> c(3, vector<int>(3, 0));
	for (int i = 0; i < 3; i++)
	{
		for (int j = 0; j < 3; j++)
		{
			cin >> c[i][j];
		}
	}

	a[0] = 0;
	b[0] = c[0][0] - a[0];
	b[1] = c[0][1] - a[0];
	b[2] = c[0][2] - a[0];
	a[1] = c[1][0] - b[0];
	a[2] = c[2][0] - b[0];

	for (int i = 0; i < 3; i++)
	{
		for (int j = 0; j < 3; j++)
		{
			if (a[i] + b[j] != c[i][j])
			{
				cout << "No" << endl;
				return;
			}
		}
	}

	cout << "Yes" << endl;
	return;
}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	execute();

	int stop;
	cin >> stop;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
const int maxn=1e3+10;
const ll mod=20180623;
char s[maxn][maxn];
int vis[maxn][maxn];
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int res=-1;
int ex,ey;
int n,m;
struct ppp{
    int x,y,cnt;
};
ppp pp;
bool check(ppp c){
    if(c.x<1||c.x>n||c.y<1||c.y>m||(vis[c.x][c.y]!=0&&c.cnt>=vis[c.x][c.y])||s[c.x][c.y]=='#')
        return false;
    return true;
}
queue<ppp>tk;
void bfs(){
    queue<ppp>que;
    pp.cnt=1;
    que.push(pp);
    tk.push(pp);
    while(!que.empty()){
        ppp now=que.front();
        que.pop();
        if(now.x==ex&&now.y==ey){
            res=now.cnt-1;
        }
        for(int i=0;i<4;i++){
            ppp z=now;
            z.x+=dx[i];
            z.y+=dy[i];
            if(check(z)){
                vis[z.x][z.y]=z.cnt;
                que.push(z);
                tk.push(z);
            }
        }
    }
}

void bfs1(queue<ppp>t){
    queue<ppp>que=t;
    while(!que.empty()){
        ppp now=que.front();
        tk.push(now);
        que.pop();
        if(now.x==ex&&now.y==ey){
            res=now.cnt-1;
        }
        for(int i=0;i<4;i++){
            ppp z=now;
            z.x+=dx[i];
            z.y+=dy[i];
            if(check(z)){
                vis[z.x][z.y]=z.cnt;
                que.push(z);
                tk.push(z);
            }
        }
    }
}

void bfs2(){
    while(1){
        queue<ppp>temp;
        while(!tk.empty()){
            ppp now=tk.front();
            tk.pop();
            for(int i=max(1,now.x-2);i<=min(n,now.x+2);i++){
                for(int j=max(1,now.y-2);j<=min(m,now.y+2);j++){
                    if(s[i][j]=='.'&&vis[i][j]==0){
                        vis[i][j]=now.cnt+1;
                        ppp c=now;
                        c.x=i;
                        c.y=j;
                        c.cnt=now.cnt+1;
                        temp.push(c);
                    }
                }
            }
        }
        bfs1(temp);
        if(vis[ex][ey]!=0||tk.empty()){
            return;
        }
    }
}

int main(){
    scanf("%d%d",&n,&m);
    scanf("%d%d%d%d",&pp.x,&pp.y,&ex,&ey);
    for(int i=1;i<=n;i++){
        getchar();
        for(int j=1;j<=m;j++){
            scanf("%c",&s[i][j]);
        }
    }
    bfs();
    if(vis[ex][ey]==0)
        bfs2();
    printf("%d",vis[ex][ey]-1);
    return 0;
}


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

int main()
{
    int A, B;
    cin >> A >> B;
    int wa, sa, seki;
    
    wa = A + B;
    sa = A - B;
    seki = A * B;
    
    cout << max(wa, max(sa, seki)) << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> plll;
typedef pair<pll,pll> ppll;
typedef long double ld;

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define fst first
#define snd second
#define ins insert
#define pb push_back
template< typename T,typename V>ostream &operator<< (ostream &out,const pair<T,V> x){ out << "{" << x.fst << " : " << x.snd << "}"; return out;}template< typename T>ostream &operator<< (ostream &out,const set<T> x){ for(auto &it : x){ out << it << " "; } return out;}template< typename T>ostream &operator<< (ostream &out,const multiset<T> x){ for(auto &it : x){ out << it << " "; } return out;}template< typename T,typename V>ostream &operator<< (ostream &out,const map<T,V> x){ for(auto &it : x){ out << "[" << it.fst << "]" << " = " << it.snd << "\n"; } return out;}template< typename T>ostream &operator<< (ostream &out,const vector<T> x){ for(int i = 0;i < x.size() - 1; ++i){ out << x[i] << " "; } out << x.back(); return out;}template< typename T>ostream &operator<< (ostream &out,const vector<vector<T> > x){ for(int i = 0;i < x.size() - 1; ++i){ out << "[" << i << "]" << " = {" << x[i] << "}\n"; } out << "[" << x.size() - 1 << "]" << " = {" << x.back() << "}\n"; return out;}

const int N = 1e6 + 5;
const int MOD = 1e9 + 7;
const int INF = 1e9;
main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    //freopen(".in", "r", stdin);
    //freopen(".out", "w", stdout);
    ll h,n;
    cin >> h >> n;
    for(int i = 0;i < n; ++i){
        ll x;
        cin >> x;
        h -= x;
    }
    if(h <= 0)cout << "Yes";else cout << "No";
    return 0;
}



Measured memory_bytes: 256
/*

    author : s@if

*/

#include<bits/stdc++.h>
using namespace std;

#define 		NIL 			-1
#define		 	fi	 		    first
#define 		sec 			second
#define 		MAX 			INT_MAX
#define			INF 			99999999
#define 		ll 			    long long
#define 		PI 			    acos(-1.0)
#define			MOD 			1000000007
#define 		PLL 			pair<ll,ll>
#define 		PII			    pair<int,int>
#define 		ull 			unsigned long long
#define 		For(i,a,b) 		for(int i=a;i<=(int)b;i++)


bool Check(int N , int pos)	{	return (bool) (N & (1<<pos));}
int Set(int N, int pos) {	return N = N | (1<<pos);}

int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};
int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};
int hr[]={-2,-2,-1,+1,+2,+2,-1,+1};
int hc[]={+1,-1,+2,+2,-1,+1,-2,-2};
int dx[]={+1,-1,+0,+0};
int dy[]={+0,+0,+1,-1};

const int MAXN = (int)1e5+9;

ll ara[MAXN];
vector<PLL>qry;

int main()
{
/*	freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);  */

    ll i,j,k,l,m,n,p,q,x,y,u,v,r,tc,t;

    cin>>n>>m;

    For(i,1,n)
    {
        cin>>ara[i];
    }

    sort(ara+1,ara+n+1);

    For(i,1,m)
    {
        cin>>p>>q;

        qry.push_back(PLL(q,p));
    }

    sort(qry.begin(),qry.end());
    reverse(qry.begin(),qry.end());

    ll ans = 0;

    j = 1;
    for(i=0; i<m; i++)
    {
        x = qry[i].sec;
        y = qry[i].fi;

        k = 1;
        while(j<=n && k<=x && ara[j]<y)
        {
            ans+=y;
            k++;
            j++;
        }
    }

    while(j<=n)
        ans+=ara[j] , j++;

    cout<<ans<<endl;

   // main();

    return 0;
}


Measured memory_bytes: 3188
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String[] s = new String[n];
        for (int i = 0; i < s.length; i++) {
            s[i] = sc.next();
        }
        Map<String, Integer> map = new HashMap<>();
        long result = 0;
        for (int i = 0; i < s.length; i++) {
            char[] c = s[i].toCharArray();
            Arrays.sort(c);
            String str = new String(c);
            if (map.keySet().contains(str)) {
                result += map.get(str);
                map.put(str, map.get(str) + 1);
            } else {
                map.put(str, 1);
            }
            
        }
        System.out.println(result);
        sc.close();
    }
}

Measured memory_bytes: 52676
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define WORDS 26

void histgram_str(char *str,int n,int *list){
  int i;
  for(i=0;i<n;i++)
    if('a'<=str[i]&&str[i]<='z')
      list[str[i]-'a']++;
    else if('A'<=str[i]&&str[i]<='Z')
      list[str[i]-'A']++;
}

int main(void){
  int i,n,list[WORDS]={0};
  char *str;

  //?????????????????????
  n=100000;
  str=(char *)malloc(sizeof(char)*n);
  while((str[i++]=getchar())!=EOF);
  n=i;
  histgram_str(str,n,list);
  //???????????°????????¨???
  for(i=0;i<WORDS;i++)
    printf("%c : %d\n",'a'+i,list[i]);
  
  free(str);
  return(0);
}

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

#define endl '\n'
#define fi first
#define se second
#define MOD(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,n) for (int i = 0; i < n; i++)
#define forr(i,a,b) for (int i = a; i <= b; i++)
#define all(v) v.begin(), v.end()
#define pb(x) push_back(x)

using namespace std;

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



int main () {
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	int r;
	cin >> r;
	cout << fixed << setprecision(4) << 3.141593 * 2 * r << endl;	

	return 0;
}


Measured memory_bytes: 3780
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

void main() {
    auto hw = readints;
    int h = hw[0], w = hw[1];

    writeln(repeat('#', w + 2));
    for (int i = 0; i < h; i++) {
        auto s = read!string;
        writeln("#", s, "#");
    }
    writeln(repeat('#', w + 2));
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
using lint = long long int;
long long int INF = 1001001001001001LL;
int inf = 1000000007;
long long int MOD = 1000000007LL;
double PI = 3.1415926535897932;

template<typename T1,typename T2>inline void chmin(T1 &a,const T2 &b){if(a>b) a=b;}
template<typename T1,typename T2>inline void chmax(T1 &a,const T2 &b){if(a<b) a=b;}

#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()

/* do your best */

lint n, k, c;

void culc1(string s, vector<lint> &dp) {
  
  for (int i = 1; i <= n; i++) {
    // i 番めまで処理して，何日間働けたか
    
    // not
    dp[i] = max(dp[i], dp[i - 1]);

    // take
    if (s[i - 1] == 'o' and i - c - 1 >= 0) dp[i] = max(dp[i], dp[i - c - 1] + 1);
    else if (s[i - 1] == 'o') {
      dp[i] = max(dp[i], 1LL);
    }
  }

}

void culc2(string s, vector<lint> &dp) {
  
  for (int i = n; i >= 1; i--) {
    // i 番めまで処理して，何日間働けたか
    
    // not
    dp[i] = max(dp[i], dp[i + 1]);

    // take
    if (s[i - 1] == 'o' and i + c + 1 <= n + 1) dp[i] = max(dp[i], dp[i + c + 1] + 1);
    else if (s[i - 1] == 'o') {
      dp[i] = max(dp[i], 1LL);
    }
  }
  
}

int main() {
  
  cin >> n >> k >> c;
  string s; cin >> s;
  vector<lint> dp1(n + 1, 0);
  vector<lint> dp2(n + 2, 0);
  culc1(s, dp1);
  culc2(s, dp2);

  /*for (int i = 1; i <= n; i++) {
    cerr << dp1[i] << " ";
  }
  cerr << endl;
  for (int i = 1; i <= n; i++) {
    cerr << dp2[i] << " ";
  }
  cerr << endl;*/

  vector<int> ans;
  for (int i = 1; i <= n; i++) {
    if (s[i - 1] == 'x') continue;
    if (dp1[i - 1] + dp2[i + 1] >= k) continue;
    ans.push_back(i);
  }

  for (auto x : ans) cout << x << endl;
  return 0;
}


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

static const int MAX = 100;
static const int INFTY = (1<<21);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n,M[MAX][MAX];

int prim(){
    int u,minv;
    int d[MAX],p[MAX],color[MAX];
    
    for(int i=0; i<n; i++){
        d[i] = INFTY;
        p[i] = -1;
        color[i] = WHITE;
    }
    
    d[0] = 0;
    
    while(1){
        minv = INFTY;
        u = -1;
        for(int i=0; i<n; i++){
            if(minv > d[i] && color[i] != BLACK){
                u = i;
                minv = d[i];
            }
        }
        if(u==-1) break;
        color[u] = BLACK;
        for(int v=0; v<n; v++){
            if(color[v]!=BLACK && M[u][v] != INFTY){
                if(d[v] > M[u][v]){
                    d[v] = M[u][v];
                    p[v] = u;
                    color[v] = GRAY;
                }
            }
        }
    }
    
    int sum = 0;
    for(int i=0; i<n; i++){
        if(p[i] != -1) sum+= M[i][p[i]];
    }
    return sum;
}

int main(){
    cin >> n;
    
    for(int i=0; i<n; i++){
        for(int j=0; j<n; j++){
            int e; cin >> e;
            M[i][j] = (e == -1) ? INFTY : e;
        }
    }
    
    cout << prim() << endl;
    
    return 0;
}

Measured memory_bytes: 3084