akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<string.h>

// study of Hash table.

#define M 1020001  // large prime number. 
#define L 14       // length of term.

char H[M][L];     // Hash table.

int getnum(char ch)  // character to number.
{
    if(ch == 'A'){ return 1; }
    else if(ch == 'C'){ return 2; }
    else if(ch == 'G'){ return 3; }
    else{ return 4; }
    return 0;
}

long long getkey(char word[])   // string to key.
{
    int sum = 0, p = 1, i;
    for(i = 0; word[i]; i++){
        sum = sum + p * getnum(word[i]);
        p = p * 5;
    }
    return sum;
}

int h1(int k){ return k % M; }   
int h2(int k){ return 1 + (k % (M - 1)); }  

int insert(char str[])
{
    int key, h, i;
    key = getkey(str);

    for(i = 0; ; i++){
        h = (h1(key) + i * h2(key)) % M;    // hash.
        if(strcmp(H[h], str)){  
            if(strlen(H[h]) == 0){ strcpy(H[h], str); return 1; }
        }else{ return 0; }
    }
    return 0;
}

int find(char str[])
{
    int key, h, i;
    key = getkey(str);

    for(i = 0; ; i++){
        h = (h1(key) + i * h2(key)) % M;
        if(strcmp(H[h], str)){
            if(strlen(H[h]) == 0){ return 0; } continue; }
            else{ return 1; }
    }
    return 0;
}

int main()
{
    char com[9], word[14];
    int NumOfCom;
    scanf("%d", &NumOfCom);

    for(int i = 0; i < M; i++) H[i][L] = '\0';  // initialize.

    while(NumOfCom){
        scanf("%s %s", &com, &word);
        if(com[0] == 'i'){ insert(word); }
        else{
            if(find(word)){ printf("yes\n"); }
            else{ printf("no\n"); }
        }
        NumOfCom--;
    };
    return 0;
}

Measured memory_bytes: 14976
import sys

d = { chr(i): 0 for i in range(97, 123) }
s = [i for i in sys.stdin]
for i in s:
    i = list(i)
    for c in i:
        try: 
            d[c.lower()] += 1
        except:
            continue
for i,j in d.items():
    print('{} : {}'.format(i,j))


Measured memory_bytes: 5568
#include <bits/stdc++.h>
 using namespace std;
int main(){
  long n,m,j,ans,c;
  long long k,s;
  cin >> n;
  s = 0;
  for(int i=1;i<=n;i++){
    k = n/i;
    //cout << i << ":" << k << endl;
    s += k*(k+1)/2 * i;
  }
  cout << s << endl;
}

Measured memory_bytes: 3620
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
using ll=long long;
int main() {
	int n;
	ll x;
	cin >> n >> x;
	vector<ll>v(n),sub;
	for (int i = 0; i < n; ++i)cin >> v[i];
	v.push_back(x);
	sort(v.begin(), v.end());
	reverse(v.begin(), v.end());
	for (int i = 0; i < v.size()-1 ; ++i) {
		sub.push_back(v[i] - v[i + 1]);
	}
	sort(sub.begin(), sub.end());
	for (int i = 0; i < sub.size(); ++i) {
		if (sub[i] % sub[0] != 0)sub[0] = sub[i] % sub[0];
	}
	cout << sub[0] << endl; return 0;
}

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

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

    string S;
    cin >> S;

    int ans = 0;
    rep (i, N) {
        if (i != 0) {
            if (S[i] == 'L' && S[i - 1] == 'L') {
                ans += 1;
            } else if (S[i] == 'R' && S[i - 1] == 'R'){
                ans += 1;
            }
        }
    }

    cout << min(N - 1, ans + K * 2) << endl;
    return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
    ll a,b,c,d,e,f;
    cin>>a>>b>>c>>d;
    if(a>=d)
    {
      cout<<d;
    }
    else
    {
        e=d-a;
        if(e<=b)
        {
            cout<<a;
        }
        else
        {
            f=d-(a+b);
            cout<<a-f;
        }
    }
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>; // グラフ型
typedef long long ll;
#define _GLIBCXX_DEBUG

/*
 // 深さ優先探索
vector<bool> seen;
int dfs(const Graph &G, ll v) {
    seen[v] = true; // v を訪問済にする
    int score = 0; 

    // v から行ける各頂点 next_v について
    for (auto next_v : G[v]) { 
        if (seen[next_v]) continue; // next_v が探索済だったらスルー

        // 負荷さ優先探索中の処理



        dfs(G, next_v); // 再帰的に探索, 毎回mat渡してええの？
    }
    return score;
} */

/*
//桁数の計算
ll keta(ll num){
  ll ans= 0 ;
  ll rem;

  for (ll i = 4; i >= 0 ; i--){
    rem = pow(10,i);
    ans += (num / rem); 
    num = num % rem;
  }
  return ans;
}
*/


int main() {
    ll N, M, X;
    cin >> N >> M >> X;
    vector<vector<ll>> a(12, vector<ll>(M, 0));
    vector<ll> c(12, 0);
    
    for(ll i = 0; i < N; i++){
      for(ll j= 0; j < M+1; j++){
        if(j==0) cin >> c[i];
        else cin >> a[i][j-1];
      }
    }
    
    
    ll ans = 1500000;
    for (int tmp = 0; tmp < (1 << 12); tmp++) {
      bitset<12> s(tmp);
      ll mon = 0;      
      vector<ll> ability(M, 0);

      //探索中のビットに対するability計算
      for (ll i=0; i < 12; i++){
        if(s.test(i)){
          for (ll j =0; j < M; j++){
            ability[j] = ability[j] + a[i][j];
          }
        }
      }

      // X 超えてるか判定
      bool flag = true;
      for (ll j =0; j < M; j++){
        if((ability[j] - X) < 0) flag = false;
      }

      if(flag){
        for (ll i=0; i < 12; i++){
          if(s.test(i)){
            mon += c[i];   
            
          }
        }
        //cout << mon << endl;         
        ans = min(ans, mon);
      }

      
    }
    if (ans == 1500000) cout << "-1" << endl;
    else cout << ans << endl;
    /*
    for(ll i = 0; i < N; i++){
      for(ll j= 0; j < M; j++){
        cout << a[i][j] << " ";
      }
      cout << endl;
    }
    */

    return 0;


}


Measured memory_bytes: 3616
num = int(input())
list = list(map(int,input().split()))
sorted(list)
count = 0
for i in range(len(list)):
    for j in range(len(list)):
        for k in range(len(list)):
            if ( list[i] < list[j] < list[k] ) and ( list[i] + list[j] >  list[k] ):
                count += 1
print(count)

Measured memory_bytes: 9092
import java.util.Arrays;
import java.util.Collections;
import java.util.*;
class Main
{
	public static void main (String[] args)
	{
		Scanner sc=new Scanner(System.in); 
		int t,i;	
		int n=sc.nextInt();
		int w=sc.nextInt();
		long dp[][]=new long[n+1][100001];
		int v[][]=new int[n+1][2];
		for(i=1;i<=n;i++)
		{
			v[i][0]=sc.nextInt();
			v[i][1]=sc.nextInt();
		}
		Arrays.fill(dp[0], Integer.MAX_VALUE);
		dp[0][0]=0;
		long ans=0;
		for(i=1;i<=n;i++)
		{
			for(int j=1;j<=100000;j++)
			{
				int wc=v[i][1];
				if(j<wc)
					dp[i][j]=dp[i-1][j];
				else
					dp[i][j]=Math.min(dp[i-1][j], v[i][0]+dp[i-1][j-wc]);
				if(dp[i][j]<=w)
					ans=j;
			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 136540
#! /usr/bin/env python3
# -*- coding: utf-8 -*-
import math
N,K = [int(x) for x in input().split()]
ans = 0
a =[]
for i in range (1,N+1):
    n = math.ceil(math.log2(K/i))
    if n >= 0:
        ans += (1/N) *((1/2)**n)
    else:
        ans += 1/N
    a.append(n)






print(ans)

Measured memory_bytes: 7064
using System;

class P
{
    static void Main()
    {
        var s = Console.ReadLine();
        if (s == "MON") Console.WriteLine("6");
        if (s == "TUE") Console.WriteLine("5");
        if (s == "WED") Console.WriteLine("4");
        if (s == "THU") Console.WriteLine("3");
        if (s == "FRI") Console.WriteLine("2");
        if (s == "SAT") Console.WriteLine("1");
        if (s == "SUN") Console.WriteLine("7");
    }
}


Measured memory_bytes: 13140
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
int main()
{
  int n,m;cin >> n >> m;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  int sum = 0;
  rep(i,n) sum += a[i];

  int cnt = 0;
  int th;
  if( sum % (4*m) == 0) {
    th = sum / (4*m);
  }
  else {
    th = sum / (4*m) + 1;
  }
  rep(i,n) {
    if( th <= a[i] ) cnt++;
  }
  if(cnt >= m) cout << "Yes" << "\n";
  else cout << "No" << "\n";
  return 0;
}


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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

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

#define FF first
#define SS second

#define DUMP(x) cout<<#x<<":"<<(x)<<endl
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class T>
istream& operator>>(istream& is, vector<T>& xs){
  for(auto& x: xs)
	is >> x;
  return is;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

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

  string S;
  cin >> S;
  S[3] = '8';
  cout << S << endl;

  return 0;
}


Measured memory_bytes: 256
n = int(input())
A = list(map(int,input().split()))
 
counter = 0
end_judge = 0
while 1:
  
  for i in range(n):
    if A[i]%2 == 1 or A[i]==0:
      end_judge = 1
    A[i] = A[i] / 2    
      
  if end_judge == 1:
    break    
  counter += 1
  
print(counter)

Measured memory_bytes: 3060
#include<iostream>
#include<cstdint>
#include<algorithm>

int64_t const INF = 1e15;
int const MAXN = 2e5;

int64_t dp[MAXN+3][2], A[MAXN];

int main() {
  int N; std::cin >> N;
  for(int i = 0; i < N; ++i) std::cin >> A[i];
  std::fill_n(dp[0], MAXN*2, -INF);
  dp[0][1] = A[0];
  dp[1][0] = A[1];
  dp[2][0] = A[2];
  for(int i = 0; i+2 < N; ++i) {
    // i => i+2
    dp[i+2][0] = std::max(dp[i+2][0], dp[i][0] + A[i+2]);
    dp[i+2][1] = std::max(dp[i+2][1], dp[i][1] + A[i+2]);
    if(i%2) {
      // i => i+3
      dp[i+3][0] = std::max(dp[i+3][0], dp[i][0] + A[i+3]);
    } else {
      // i => i+3, i+4
      dp[i+3][0] = std::max(dp[i+3][0], dp[i][1] + A[i+3]);
      dp[i+4][0] = std::max(dp[i+4][0], dp[i][1] + A[i+4]);
    }
  }
  int64_t ans;
  if(N%2) ans = std::max(dp[N-3][1], std::max(dp[N-1][0], dp[N-2][0]));
  else ans = std::max(dp[N-1][0], dp[N-2][1]);
  std::cout << ans << std::endl;
  return 0;
}


Measured memory_bytes: 8332
import java.io.PrintWriter;
import java.util.*;

public class Main {

    Scanner sc = new Scanner(System.in);

    int h = sc.nextInt();
    int w = sc.nextInt();

    char[][] arr = new char[h][w];

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

    List<Integer> list = new ArrayList<>();

    int ans = Integer.MAX_VALUE;

    int[][] visit = new int[h][w];


    public static void main(String[] args) {
        new Main().run();
    }

    void run() {
        for (int i=0; i<h; i++) {
            arr[i] = sc.next().toCharArray();
        }

        for (int i=0; i<h; i++) {
            for (int j=0; j<w; j++) {
                visit[i][j] = Integer.MAX_VALUE;
            }
        }



        dfs(0, 0, 0);

        PrintWriter out = new PrintWriter(System.out);
        if (arr[0][0]=='#') {
            out.print(ans+1);
        } else {
            out.print(ans);
        }
//        out.print(list);
        out.flush();

    }

    int dfs(int y, int x, int cnt) {
        if (y==h-1 && x==w-1) {
            ans = Math.min(ans, cnt);
        }

        visit[y][x] = cnt;
        char c = arr[y][x];

        if (c=='.') {
            for (int i=0; i<2; i++) {
                int nx = x + dx[i];
                int ny = y + dy[i];

                if (0 <= nx && nx < w && 0 <= ny && ny < h) {
                    if (arr[ny][nx] == '.') {
                        if (cnt<visit[ny][nx]) dfs(ny, nx, cnt);
                    } else {
                        if (cnt+1<visit[ny][nx]) dfs(ny, nx, cnt + 1);
                    }
                }
            }
        } else {
            for (int i=0; i<2; i++) {
                int nx = x + dx[i];
                int ny = y + dy[i];


                if (0 <= nx && nx < w && 0 <= ny && ny < h) {
                    if (arr[ny][nx] == '.') {
                        if (cnt<visit[ny][nx]) dfs(ny, nx, cnt);
                    } else {
                        if (cnt<visit[ny][nx]) dfs(ny, nx, cnt);
                    }
                }
            }
        }
        return ans;
    }
}

Measured memory_bytes: 24404
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
	int a[4],b,c;
	cin>>a[0]>>a[1]>>a[2]>>a[3]>>b>>c;
	sort(a,a+4);
	if(b>c)swap(b,c);
	cout<<a[1]+a[2]+a[3]+c<<endl;
	return 0;
	}



Measured memory_bytes: 3132
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<cmath>
#include<math.h>
#include<algorithm>
#include<string.h>
#include <iomanip>
#include <sstream>
using namespace std;

int main() {
  long long  n;
  string s = "";
  string ss;
  int ans = 0;

  cin >> n;
  cin >> ss;

  vector<string> cnd(1000);
  for(int i = 0; i < 10; i++){
    for(int j = 0; j < 10; j++){
      for(int k = 0; k < 10; k++){
        string ii = to_string(i);
        string jj = to_string(j);
        string kk = to_string(k);
        // cout << "---- ii, jj, kk = " << ii << ", " << jj << ", " << kk << endl;

        // string tmp = to_string(i-'0') + to_string(j-'0') + to_string(k-'0');
        //i, j , k からなる文字列（順不同）を作れるか調べる
        int i_ = ss.find(ii); //iが最初に出てくる場所. カウントは0, 1, 2, ...
        if(i_ == string::npos) continue; //見つからなかったら終了
        string tmp = ss;
        tmp.erase(0, i_+1); //iが最初に出てくる場所まで削除した文字列作成
        // cout << "1: tmp = " << tmp << endl;

        int j_ = tmp.find(jj); //jが最初に出てくる場所. カウントは0, 1, 2, ...
        if(j_ == string::npos) continue; //見つからなかったら終了
        tmp.erase(0, j_+1); //iが最初に出てくる場所まで削除した文字列作成
        // cout << "2: tmp = " << tmp << endl;

        int k_ = tmp.find(kk); //jが最初に出てくる場所. カウントは0, 1, 2, ...
        if(k_ == string::npos) continue; //見つからなかったら終了

        //ここまで来たら作成可能パターンなので +1
        ans++;
        // cout << "-- i, j , k = " << i << ", " << j << ", " << k << endl;

      }
    }
  }
  cout << ans << endl;

}


Measured memory_bytes: 3704
#include <iostream>
#include <math.h>
#include <string>
#include <algorithm>
using namespace std;
int main(){
  string s;
  cin>>s;
  int k;
  int rorl[100000];
  for(int i=0;i<s.size();i++){ //Rとの距離
    if(s[i]=='L') rorl[i]=k;
    else k=i;
  }
  for(int i=s.size()-1;i>=0;i--){ //Lとの距離
    if(s[i]=='L') k=i;
    else rorl[i]=k;
  }
  int answer[100000];
  for(int i=0;i<s.size();i++) answer[i]=0;
  for(int i=0;i<s.size();i++){
    if(s[i]=='L'){
      if((i-rorl[i])%2==0) answer[rorl[i]]++;
      else answer[rorl[i]+1]++;
    }
    else{
      if((rorl[i]-i)%2==0) answer[rorl[i]]++;
      else answer[rorl[i]-1]++;
    }
  }
  for(int i=0;i<s.size();i++){
    if(i<s.size()-1) cout<<answer[i]<<' ';
    else cout<<answer[i]<<endl;
  }
  
  return 0;
}

Measured memory_bytes: 4500
#include <iostream>
#include <vector>
#include <bitset>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
using pii = pair<int, int>;
using pll = pair<LL, LL>;
char A[7][8];
int nr_black_line[7], nr_black_col[7];
int H, W, K, res, tot_nr_black;


void choose_cols(const int &cur_nr_cols, const int &max_nr_cols, const vector<int> &chosen_lines,
                 const int &del_line_black, const int &last_chosen)
{
    static int offset = 0;
    static int del_col_black = 0;
    
    if (cur_nr_cols == max_nr_cols)
    {
        int del_total_black = del_col_black + del_line_black - offset;

        if (tot_nr_black - del_total_black == K)
        {
            ++res;
        }

        return;
    }

    for (int j = last_chosen + 1; j + max_nr_cols - 1 - cur_nr_cols <= W; ++j)
    {
        del_col_black += nr_black_col[j];
        for (const int &line : chosen_lines)
        {
            offset += A[line][j] == '#';
        }

        choose_cols(cur_nr_cols + 1, max_nr_cols, chosen_lines, del_line_black, j);

        for (const int &line : chosen_lines)
        {
            offset -= A[line][j] == '#';
        }
        del_col_black -= nr_black_col[j];
    }
}


void choose_lines(const int &cur_nr_lines, const int &max_nr_lines, const int &max_nr_cols, const int &last_chosen)
{
    static vector<int> chosen_lines;
    static int del_line_black = 0;
    
    if (cur_nr_lines == max_nr_lines)
    {
        choose_cols(0, max_nr_cols, chosen_lines, del_line_black, 0);
        return;
    }

    for (int i = last_chosen + 1; i + max_nr_lines - 1 - cur_nr_lines <= H; ++i)
    {
        del_line_black += nr_black_line[i];
        chosen_lines.emplace_back(i);

        choose_lines(cur_nr_lines + 1, max_nr_lines, max_nr_cols, i);

        del_line_black -= nr_black_line[i];
        chosen_lines.pop_back();
    }
}


int main()
{
    cin.sync_with_stdio(0);

    cin >> H >> W >> K;

    for (int i = 1; i <= H; ++i)
    {
        cin >> (A[i] + 1);
        for (int j = 1; j <= W; ++j)
        {
            nr_black_line[i] += A[i][j] == '#';
            nr_black_col[j] += A[i][j] == '#';
            tot_nr_black += A[i][j] == '#';
        }
    }

    for (int nr_lines = 0; nr_lines <= H; ++nr_lines)
    {
        for (int nr_cols = 0; nr_cols <= W; ++nr_cols)
        {
           choose_lines(0, nr_lines, nr_cols, 0);
        }
    }

    cout << res;
}

Measured memory_bytes: 3640
import java.util.Scanner;
public class Main{
 public static void main(String[] Args){
    Scanner sc = new Scanner(System.in);
   int a=sc.nextInt(),b=sc.nextInt(),c=sc.nextInt();
   if (a<=c && a+b>=c) System.out.print("YES");
   else System.out.print("NO");
 }
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
#define inf 1000000007
int main() {
  int n;
  long long sum = 0, ans = 0;
  cin >> n;
  vector< long long > vc(n + 1);
  for (int i = 1; i <= n; i++) {
    cin >> vc[i];
    sum += vc[i];
  }
  for (int i = 1; i < n; i++) {
    ans += ((sum - vc[i]) % inf * vc[i]) % inf;
    sum -= vc[i];
    ans %= inf;
  }
  cout << ans % inf;
  return 0;
}

Measured memory_bytes: 4848
n,k = map(int,input().split())
d_L = list(map(str,input().split()))

a_L = [str(val) for val in range(10)]

use_num = list(set(a_L) - set(d_L))

ans = 0
while True:
    c = list(set(list(str(n)))) + use_num
    if len(use_num) == len(list(set(c))):
        print(n)
        exit()

    n += 1

Measured memory_bytes: 41196
#include <bits/stdc++.h>
#define N 1001
using namespace std;

int num[3];
int vis[N], e[N][N], f[N][N];
int n, m, cnt;

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

bool dfs(int k, int col) {
	vis[k] = col;
	num[col]++;
	for (int i = 1; i <= n; ++i) {
		if (!e[k][i]) {
			if (!vis[i]) {
				if (!dfs(i, 3 - col)) return 0;
			} else {
				if (vis[i] == col) return 0;
			}
		}
	}
	return 1;
}

int main() {
	n = read(), m = read();
	for (int i = 1; i <= m; ++i) {
		int x = read(), y = read();
		e[x][y] = e[y][x] = 1;
	}
	for (int i = 1; i <= n; ++i) e[i][i] = 1;
	f[0][0] = 1;
	for (int i = 1; i <= n; ++i) {
		if (!vis[i]) {
			num[1] = num[2] = 0;
			if (!dfs(i, 1)) {
				puts("-1");
				return 0;
			}
			cnt++;
			for (int j = 0; j <= n; ++j) {
				if (f[cnt - 1][j]) {
					f[cnt][j + num[1]] = 1;
					f[cnt][j + num[2]] = 1;
				}
			}
		}
	}
	int ans = 1e9;
	for (int i = 0; i <= n; ++i) {
		if (f[cnt][i]) {
			ans = min(ans, (i - 1) * i / 2 + (n - i - 1) * (n - i) / 2);
		}
	}
	printf("%d\n", ans);
}

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

int main()
{
  int64_t N, K, a;
  cin >> N >> K;
  vector<int64_t> A(N), X(N, -1);
  for (int64_t i = 0; i < N; i++)
  {
    cin >> a;
    a--;
    A.at(i) = a;
  }
  X.at(0) = 0;
  int64_t from = 0;
  for (int64_t i = 1; i <= N + 2; i++)
  {
    int64_t to = A.at(from);
    if (i == K)
    {
      cout << to + 1 << endl;
      return 0;
    }
    if (X.at(to) == -1)
    {
      X.at(to) = i;
      from = to;
      continue;
    }
    int64_t cycle = i - X.at(to);
    int64_t init = X.at(to), k = (K - X.at(to)) % cycle;
    for (int64_t j = 0; j < N; j++)
    {
      if (X.at(j) != -1 && (X.at(j) - init) == k)
      {
        cout << j + 1 << endl;
        return 0;
      }
    }
  }
}

Measured memory_bytes: 6404
#include <bits/stdc++.h>
using namespace std;
vector<int> buf;

int main(){
  
  int N,M,Q;
  cin >> N >> M >> Q;
  int A[Q],B[Q],C[Q],D[Q];
  for(int i=0;i<Q;i++){
    cin >> A[i] >> B[i] >> C[i] >> D[i];
    A[i]--; B[i]--;
  }
  
  //全探索
  int E[N];
  for(int i=0;i<N;i++) E[i]=1;
  
  int MaxScore=0;
  bool ok=true;
  while(ok){
    
    int score=0;
    for(int i=0;i<Q;i++){
      if(E[B[i]]-E[A[i]]==C[i]) score += D[i];
    }
    if(MaxScore < score) MaxScore = score;
    
    int k=N-1;
    while(E[k]==M) k--;
    if(k==-1) ok = false;
    else{
      E[k]++;
      for(int p=k+1;p<N;p++) E[p]=E[k];
    }
    
  }
  
  cout << MaxScore << endl;
  
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define MAXN 262144
#define rint register int
inline int rf(){int r;int s=0,c;for(;!isdigit(c=getchar());s=c);for(r=c^48;isdigit(c=getchar());(r*=10)+=c^48);return s^45?r:-r;}
int A[MAXN+5], Ans[MAXN+5], n, k; vector<int> R[MAXN+5]; inline bool Amax(int i, int j){return A[i]^A[j]?A[i]>A[j]:i<j;}
void Merge(int a, int b){for(auto v:R[b]) R[a].push_back(v); sort(R[a].begin(),R[a].end(),Amax); R[a].erase(unique(R[a].begin(),R[a].end()),R[a].end()); R[a].resize(min((int)R[a].size(),2));}
int main()
{
	k = rf(); n = 1<<k; generate(A,A+n,rf); for(rint i = 0; i < n; R[i].push_back(i), i++); for(rint i = 0, j; i < n; i++) for(j = 1; j < n; i&j ? Merge(i,i^j),0 : 0, j <<= 1);
	for(rint i = 1; i < n; Ans[i] = Ans[i-1], R[i].size()>1?Ans[i]=max(Ans[i],A[R[i][0]]+A[R[i][1]]):0, printf("%d\n",Ans[i]), i++); return 0;
}

Measured memory_bytes: 19456
#!/bin/bash
''':'
docker run --rm -it -v $(cd $(dirname $0) && pwd):/vo:ro pypy:3-2.4.0 \
   /bin/bash -c "pypy3 /vo/$(basename $0) < /vo/input.txt"
exit $?
'''
import sys


def _s(): return sys.stdin.readline().strip()


def main():
    p = {"ABC", "ARC"} - set((_s(),))
    return p.pop()


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


Measured memory_bytes: 61636
//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素



signed main(){
  int H1,M1,H2,M2,K;
  cin>>H1>>M1>>H2>>M2>>K;
  int time=H2*60+M2-(H1*60+M1);
  cout<<time-K<<endl;
}

Measured memory_bytes: 3616
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<string>
#define rep(i,N) for(int i=0;i<N;i++)

long long  INF=1000000000000000000;
long long mod=1000000007;
using namespace std;

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

vector<int> l(N);
rep(i,N)cin>>l[i];

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



long long ans=0;
long long rui=0;
int large=N-1;
for(int i=N-3;i>-1;i--){
    large=N-1;
    for(int k=N-2;k>i;k--){
        //auto Mit=v.lower_bound(l[i]+l[i+k]);
        rui=0;
        for(int t=large;t>k;t--){
            if(l[i]+l[k]>l[t]){
                rui+=t-k;
                large=t;//条件を満たすものでもっとも大きいものの番号
                break;
            }
            if(t==k+1){
                large=k;
            }
        }
        ans+=rui;
    }
}
cout<<ans<<endl;

 return 0;
}
/*
4
3 4 2 1

1

3
1 1000 1

0

7
218 786 704 233 645 728 389

23
*/

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

int main() {
  int n; cin >> n;
  for (int i = 3; i <= n; i++) {
    if (i % 3 == 0) cout << " " << i;
    else {
      int x = i;
      while (x > 0) {
        if (x % 10 == 3) {
          cout << " " << i;
          break;
        }
        x /= 10;
      }
    }
  }
  cout << endl;
}


Measured memory_bytes: 3108
N = int(input())
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]

mass_prepare = []
change_count = 0
total_minus = 0
for i in range(N):
    diff = A[i] - B[i]
    if diff < 0:
        change_count += 1
        total_minus += diff
    elif diff > 0:
        mass_prepare.append(diff)
mass_prepare.sort()
mass_prepare.reverse()
total = 0
for i in range(len(mass_prepare)+1):
    if total >= abs(total_minus):
        print(i+change_count)
        break
    if i == len(mass_prepare):
        print(-1)
        break
    total += mass_prepare[i]


Measured memory_bytes: 18356
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<sstream>
#include<complex>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()

using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef complex<double> P;

#define MAX 1010

int main(){
  char buff[1000];
  while(fgets(buff,sizeof(buff),stdin)){
    int cnt = 1;
    for(char *p = buff; *p; p++){
      if(*p == '@'){
	p++;
	cnt = *p - '0'; 
      }else{
	while(cnt --> 0) putchar(*p);
	cnt = 1;
      }
    }
  }
  return 0;
}

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

#define REP(i, m, n) for (int i = (m); i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define mp make_pair
typedef long long ll;
const ll INF = 1LL << 60;
const ll mod = 1e9 + 7;
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 (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}

int N, M, P;
int A[5000], B[5000], C[5000];
int main() {
    cin >> N >> M >> P;
    rep(i, M) {
        cin >> A[i] >> B[i] >> C[i];
        A[i]--; B[i]--;
        C[i] = -C[i];
    }

    ll dist[2500];
    rep(i, N) dist[i] = INF;
    dist[0] = 0;

    rep(k, N-1) {
        rep(i, M) {
            if (dist[A[i]] == INF) continue;
            if (dist[B[i]] > dist[A[i]] + C[i] + P) {
                dist[B[i]] = dist[A[i]] + C[i] + P;
            }
        }
    }

    ll ans = dist[N-1];
    bool negative[2500];
    rep(i, N) negative[i] = false;

    rep(k, N) {
        rep(i, M) {
            if (dist[A[i]] == INF) continue;
            if (dist[B[i]] > dist[A[i]] + C[i] + P) {
                dist[B[i]] = dist[A[i]] + C[i] + P;
                negative[B[i]] = true;
            }
            if (negative[A[i]] == true) negative[B[i]] = true;
        }
    }

    if (negative[N-1]) cout << "-1" << endl;
    else if (ans > 0) cout << 0 << endl;
    else cout << -ans << endl;

    return 0;

}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define SORT(x) sort((x).begin(),(x).end())
int main(void){
    
    int a, b, c, d;
    cin >>a >>b >>c >>d;
    
    if(abs(a-c)<=d){
        cout <<"Yes";
    }else if((abs(a-b)<=d)&&(abs(b-c)<=d)){
        cout <<"Yes";
    }else{
        cout <<"No";
    }
    
    cout <<endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
 
using namespace ::std;
 
#define all(x)  x.begin(),x.end()
#define Unique(x) x.erase(unique(all(x)), x.end())
 
template< class T > T SQR(T N) {return (T) N * N;}
template< class T > double DIST(T a, T b) {return 1.0 * sqrt(SQR(double(a)) + SQR(double(b)));}
template< class T > bool CROSS(pair< T,T > a, pair< T,T > b, pair< T,T > c) {return (b.first - a.first) * (c.second - b.second) >= (b.second - a.second) * (c.first - b.first);}
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair< int,int > pi;
 
int px[] = {0, 1, -1, 0, -1, -1, 1, 1};
int py[] = {1, 0, 0, -1, -1, 1, -1, 1};
 
double EPS = 1e-9;
double PI = acos(-1);
double GR = 1.6180339887498948;

vector< int >Pr;

inline void Seive()
{
    bool a[15007]{};
    Pr.push_back(2);
    for(int i = 4; i<=15005; i += 2) a[i] = 1;
    for(ll i = 3; i * i <(1505); i += 2) if(!a[i]) {for(ll j = i * i; j <= 15005; j = j + 2 * i) a[j] = 1;}
    for(int i = 3; i<= 15005; i += 2) if(!a[i]) Pr.push_back(i);
}
 
inline ll power(ll a, ll p, ll mod)
{
    ll x = a, res = 1;
 
    while(p)
    {
        if(p&1) res = (res * x)%mod;
        p /= 2, x = (x * x)%mod;
    }
    return res;
}
 
int F[207];
 
inline void Fail(string str)
{
    string s = str;
    reverse(all(s));
 
    s = s + "#" + str;
 
    int len = s.length();
 
    for(int i = 1; i<len; ++i)
    {
        int j = F[i - 1];
        while (j > 0 and s[i] != s[j])
            j = F[j - 1];
         if(s[i] == s[j]) ++j;
         F[i] = j;
    }
}
 
// ll Pow[500007];
// ll bit[500007];
// ll mod = 998244353LL;
 
// struct BIT
// {
//     inline void UPDATE(int idx, int n, int val)
//     {
//         for(int i = idx; i<=n; i += (i&-i))
//             bit[i] = (bit[i] + (Pow[idx] * val)%mod)%mod;
//     }
 
//     inline ll Sum(int idx)
//     {
//         ll ss = 0;
//         for(int i = idx; i; i -= (i & -i))
//             ss = (ss + bit[i])%mod;
//         return ss;
//     }
// };

// inline int SMALL_GIANT(ll a, ll rem, ll mod)
// {
//     a %= mod, rem %= mod;

//     ll k = 1, step = 0, gcd;
//     while((gcd = __gcd(a, mod)) > 1)
//     {
//         if(k == rem) return step;
//         if(rem%gcd) return -1;
//         rem /= gcd, mod /= gcd, ++step;
//         k = (k * (a/gcd))%mod;
//     }

//     int n = sqrt(mod) + 1;
//     unordered_map< int,int >mp;

//     ll xx = 1, cur = rem, xxx = k;
//     for(int i = 0; i<n; ++i) xx = (xx * a)%mod;

//     for(int q = 0; q <= n; ++q)
//         mp[cur] = q, cur = (cur * a)%mod;

//     for(int p = 1; p <=n; ++p)
//     {
//         xxx = (xxx * xx)%mod;
//         if(mp[xxx]) return p * n - mp[xxx] + step;
//     }
//     return -1;
// }

//vector< int >graph[200000];


int main()
{
    //cin.tie(0); cout.tie(0);
 
    int n, m, c, d, a, b, k;
    int test;
    
    // scanf("%d", &test);
    // for(int t = 1; t<=test; ++t)
    // {
    //     scanf("%d%d", &k, &b);


    // }

    scanf("%d%d", &n, &m);
    
    c = 0;
    for(int i = 0; i<n; ++i)
    {
        scanf("%d%d", &a, &b);

        ll x = SQR(ll(a)) + SQR(ll(b));
        ll y = SQR(ll(m));
        if(x <= y) ++c;
    }
    printf("%d\n", c);
}

Measured memory_bytes: 3824
solver::([Char],[Char],[Char])->Char->String
solver ([],_,_) 'a'= "A"
solver (_,[],_) 'b'= "B"
solver (_,_,[]) 'c'= "C"
solver (a:as,bs,cs) 'a'= case a of
                    'a' -> solver (as,bs,cs) 'a'
                    'b' -> solver (as,bs,cs) 'b'
                    'c' -> solver (as,bs,cs) 'c'
solver (as,b:bs,cs) 'b'= case b of
                    'a' -> solver (as,bs,cs) 'a'
                    'b' -> solver (as,bs,cs) 'b'
                    'c' -> solver (as,bs,cs) 'c'
solver (as,bs,c:cs) 'c'= case c of
                    'a' -> solver (as,bs,cs) 'a'
                    'b' -> solver (as,bs,cs) 'b'
                    'c' -> solver (as,bs,cs) 'c'

main::IO()
main =do
  as<-getLine
  bs<-getLine
  cs<-getLine
  putStr ((solver (as,bs,cs) 'a')++"\n")


Measured memory_bytes: 508
n = gets.to_i
arr = gets.chomp.split('')
r_num = 0
arr.each do |c|
  if c == "R"
    r_num += 1
  end
end
re_r_num = 0
i = 0
while i < r_num
  if arr[i] == "R"
    re_r_num += 1
  end
  i += 1
end
print r_num - re_r_num 


Measured memory_bytes: 30644
# Aizu Problem 0089: The Shortest Path on A Rhombic Path
#
import sys, math, os

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")


rhombic = [[int(_) for _ in line.split(',')] for line in sys.stdin]
n = len(rhombic)
sums = [rhombic[0][0]]
for k in range(1, n // 2 + 1):
    row = [sums[0] + rhombic[k][0]]
    for i in range(1, len(rhombic[k-1])):
        row.append(rhombic[k][i] + max(sums[i-1], sums[i]))                
    row.append(sums[-1] + rhombic[k][-1])
    sums = row[:]
for k in range(n // 2 + 1, n):
    row = []
    for i in range(len(rhombic[k])):
        row.append(rhombic[k][i] + max(sums[i], sums[i+1]))                
    sums = row[:]
print(sums[0])
    

Measured memory_bytes: 7780
from bisect import bisect_left
n, k = map(int, input().split())
candles = list(map(int, input().split()))
point_zero = bisect_left(candles, 0)
candles.insert(point_zero, 0)
ans = float('inf')
for i in range(min(k, point_zero) + 1):
    left = point_zero - i
    right = point_zero + k - i
    if (0 <= left) and (right < n + 1):
        dis = -candles[left] + candles[right] + min(-candles[left], candles[right])
        ans = min(ans, dis)
print(ans)

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


int main() {

  int N,a,b,max_man,out_man;
  int A[210];         // 最大 200 個なので余裕を持って 210 に --- 200 以上ならなんでもよいです

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

    int res = 0;
    max_man = 0;
    out_man = 1;
        for (int i = 1; i <= N; ++i) {
            a = 0;
            b = i;
            //cout << i << endl;
            for (int j = 0; a < 1 ; ++j) {  
                 // cout << b << endl;   
              
                  if (b % 2 < 1){                  
                      b /= 2; 
                    
                  }else {
                       a = 1;
                       //cout << "tooyayo" << endl;          
                   }


                  if (max_man <= j) {
                    max_man = j;
                    out_man = i;
                  } 
                
               }
                                    



        }
    cout << out_man << endl;
}

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

int dpw(int x){
  int a=1;
  while(x){
    a*=2; x--;
  }
  return a;
}

int main(){
  int N,M;
  cin>>N>>M;
  int al=dpw(N);
  vector<vector<int>> S(M);
  for(int i=0;i<M;i++){
    int k; cin>>k;
    for(int j=0;j<k;j++){
      int b;cin>>b;b--;
      S[i].push_back(b);
    }
  }
  vector<int> p(M);
  for(int i=0;i<M;i++)
    cin>>p[i];
  vector<int> X(N);
  vector<int> Y(M,0);
  int cnt=0;
  for(int i=0;i<al;i++){
    int q=i;
    for(int j=0;j<N;j++){
      X[j]=q%2;
      q/=2;
    }
    bool jd=true;
    for(int j=0;j<M;j++){
      Y[j]=0;
      for(int k=0;k<S[j].size();k++){
        if(X[S[j][k]])
          Y[j]++;
      }
      if(Y[j]%2!=p[j]){
        jd=false;break;
      }
    }
    if(jd) cnt++;
  }
  cout<<cnt<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define pi 3.14159265358979
#define mod 1000000007
#define rep(i,n) for(ll i=0;i<n;i++)
using namespace std;

int main(){
    ll n,k,a[200005],max=0;
    cin >>k>>n;
    rep(i,n){
        cin>>a[i];
        if(i>0){
            if(max<a[i]-a[i-1]){
                max=a[i]-a[i-1];
            }
        }
    }
    if(max<k+a[0]-a[n-1]){
        max=k+a[0]-a[n-1];
    }
    cout << k-max;
}

Measured memory_bytes: 5188
import bisect

n = int(input())
l = list(map(int, input().split()))
ans = 0
l.sort()
for i in range(n-1, -1, -1):
    a = l[i]
    for j in range(i-1, -1, -1):
        b = l[j]
        c = bisect.bisect_right(l, a-b, lo=0, hi=j)
        ans = ans + j-c
print(ans)


Measured memory_bytes: 43740
// Reading stuff 
// check the modulus 
// for tree case n=1


#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse2")
 
#include <bits/stdc++.h>
#include <vector> 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;

#define int         long long
#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define mp          make_pair
#define all(a)      (a).begin(),(a).end()
#define FF           first
#define SS           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define rep(i,a,b)  for(int i=a;i<b;i++)
const ll hell=1000000007;
const ll mod=998244353;



int solve(){    
 
  int n,k;
  cin>>n>>k;

  int dp[n+2]={0};
  dp[0]=0;
  dp[1]=0;
  rep(i,2,n+2)dp[i]=(dp[i-1]+i-1+hell)%hell;

  int ans=0;

  rep(i,k,n+2)
  {  
     //cout<<dp[n+1]-dp[n-i+1]<<" "<<dp[i]<<endl;
     ans+=(dp[n+1]-dp[n-i+1]-dp[i]+1);
     ans+=2*hell;
     ans%=hell;
  }

  cout<<ans<<endl;


return 0;
}

 
signed main()
{    



   ios::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);


int t=1;                                                                                                                  
//cin>>t;
int k=1;

    while(t--)
     {
      //cout<<"Case #"<<k<<": ";
      k++;
      solve();
     }
    return 0;
  }

Measured memory_bytes: 5144
#include <iostream>

using namespace std;

int main()
{
    int N, M, X, Y, x_max, y_min;

    cin >> N >> M >> X >> Y;
    x_max = X;
    y_min = Y;
    for (int i = 0; i < N; i++) {
        cin >> X;
        x_max = max(X, x_max);
    }
    for (int j = 0; j < M; j++) {
        cin >> Y;
        y_min = min(Y, y_min);
    }

    cout << (y_min - x_max > 0 ? "No War" : "War") << endl;
}

Measured memory_bytes: 256
c,d,t,u;
long s;
main()
{
	c=getchar_unlocked();
	while(c-10)
	{
		t+=1;
		d=getchar_unlocked();
		if(c-d)
		{
			s+=(long)t*(t+1)/2;
			if(c=='>')s-=t<u?t:u;
			u=t;
			t=0;
			c=d;
		}
	}
	printf("%ld",s);
}

Measured memory_bytes: 128
// Ver19.03
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define INF (1 << 29) * 2
#define LLINF 4545454545454545454
#define MOD 1000000007
#define ll long long
#define ull unsigned long long
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
int upll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? -1 : *(ll *)a > *(ll *)b ? 1 : 0; }
int downll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? 1 : *(ll *)a > *(ll *)b ? -1 : 0; }
void sortup(ll *a, int n) { qsort(a, n, sizeof(ll), upll); }
void sortdown(ll *a, int n) { qsort(a, n, sizeof(ll), downll); }

int main()
{
  ll h, n;
  scanf("%lld%lld", &h, &n);
  for (int i = 0; i < n; i++)
  {
    ll a;
    scanf("%lld", &a);
    h -= a;
  }
  puts(h <= 0 ? "Yes" : "No");
}

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

#define MAX_N 100050

int N;
long long A[MAX_N], B[MAX_N];
long long ans = 0;

void solve() {
  for (int i = 0; i < N; i++) {
    int j = min(A[i], B[i]);
    A[i] -= j;
    B[i] -= j;
    ans += j;
    int k = min(A[i+1], B[i]);
    A[i+1] -= k;
    ans += k;
  }
  
  printf("%lld\n", ans);
}

int main() {
  scanf("%d", &N);
  for (int i = 0; i < N + 1; i++) {
    scanf("%d", &A[i]);
  }
  for (int i = 0; i < N; i++) {
    scanf("%d", &B[i]);
  }

  solve();

  return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstdio>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)2e18
#define jck 3.141592

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;


int main(){
	int N,K; cin >> N >> K;
	string S; cin >> S;
	vector<int> state;
	int now = 1;
	int cnt = 0;
	rep(i,N){
		if(S[i] == now + '0') cnt++;
		else{
			now = 1-now;
			state.push_back(cnt);
			cnt = 1;
		}
	}
	if(cnt != 0) state.push_back(cnt);
	if(now == 0) state.push_back(0);
	int m = state.size();
	if(m == 1){
		cout << state[0] << endl;
		return 0;
	}
	vector<int> sum(m+1);
	rep(i,m) sum[i+1] = sum[i] + state[i];
	int ans = 0;
	for(int i = 0; i < m; i+=2){
		int now = 0;
		now += sum[min(i+2*K+1,m)] - sum[i];
		ans = max(ans,now);
	}
	cout << ans << endl;
}


Measured memory_bytes: 1272
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <map>
using namespace std;
typedef long long LL;
int n,Max;
char s[105];
map<char,bool>vis1;
map<char,bool>vis2;
int main(){
	Max=0;
	scanf("%d",&n);
	scanf("%s",s+1);
	for(int i=1;i<=n-1;i++){
		vis1[s[i]]=1;
		int cnt=0;
		vis2.clear();
		for(int j=i+1;j<=n;j++){
			if(vis1[s[j]]==1&&vis2[s[j]]==0){
				cnt++;
				vis2[s[j]]=1;
			}
		}
		if(cnt>Max) Max=cnt;
	}
	printf("%d\n",Max);
}

Measured memory_bytes: 256
n=int(input())
d=list(map(int,input().split()))

from collections import Counter
c=Counter(d)

mod=998244353
ans=1
key=set(c.keys())
if d[0]==0 and c[0]==1 and set(range(len(key))) == key:
    for i in range(len(key)):
        #print(i,c[i],c[i+1],c[i]**c[i+1])
        ans=ans*c[i]**c[i+1] %mod
else:
    ans=0
print(ans)

Measured memory_bytes: 76724
#include<iostream>

using namespace std;

int main(){
  	int k, r = 0;
  	cin>>k;
  	for(int i=0; i<=k; ++i){
    	r *= 10;
      	r += 7;
      	r %= k;
      	if(!r){
        	cout<<i + 1<<endl;
          	break;
        }
    }
  
  	if(r){
    	cout<<-1<<endl;
    }

	return 0;
}

Measured memory_bytes: 3528
using System;
using System.Collections.Generic;

enum occupant
{
build, floor, room, number
}

class Program
 {



    static void Main(string[] args)
    {
        String nyuryoku;
        string[] data = new string[3];
        string[] data1,data2;
        int m,n,l;
        int[,] matrix1, matrix2;
        double[,] matrix3;

        nyuryoku = Console.ReadLine();
        data = nyuryoku.Split(' ');
        n = int.Parse(data[0]);
        m = int.Parse(data[1]);
        l = int.Parse(data[2]);
        matrix1 = new int[n, m];
        matrix2 = new int[m, l];
        matrix3 = new double[n, l];
        data1 = new string[m];
        for (int i = 0; i < n; i++)
        {
            nyuryoku = Console.ReadLine();
            data1 = nyuryoku.Split(' ');
            for (int j = 0; j < m; j++)
            {
                matrix1[i, j] = int.Parse(data1[j]);
            }
        }
        data2 = new string[l];
        for (int i = 0; i < m; i++)
        {
            nyuryoku = Console.ReadLine();
            data2 = nyuryoku.Split(' ');
            for (int j = 0; j < l; j++)
            {
                matrix2[i, j] = int.Parse(data2[j]);
            }
        }

        for(int i=0; i < n;i++)
            for(int j=0; j < l; j++)
                for(int k = 0;k < m; k++)
                    matrix3[i,j] =matrix3[i,j] + matrix1[i,k]*matrix2[k,j];

        for (int i = 0; i < n; i++)
        {
            for (int J = 0; J < l; J++)
            {
                Console.Write("{0}", matrix3[i, J]);
                if (J < l -1)
                    Console.Write(" ");
                else
                    Console.Write("\n");
            }
        }





    }

 }



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

#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;
typedef long long ll;

int main() {
  ll n, x, ans = 0, t;
  cin >> n >> x;
  vector<ll> a(n);

  rep(i, n) cin >> a[i];

  rep(i, n - 1) {
    if (a[i] + a[i + 1] > x) {
      t = a[i] + a[i + 1] - x;
      a[i + 1] -= t;
      ans += t;
      if (a[i + 1] < 0) {
        a[i + 1] = 0;
        a[i] -= t;
      }
    }
  }

  cout << ans << endl;

  return 0;
}


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

public class ABC0129_A2v1 {
    private static void Main(string[] args) {
        var inputs = new List<string>() {
            Console.ReadLine().Trim(),
            Console.ReadLine().Trim(),
        };

        Prepare(inputs);
    }

    private static void Prepare(List<string> inputs) {
        var numOfWeights = int.Parse(inputs[0]);
        var weightsStr = inputs[1].Split();
        var weights = weightsStr.Select(x => int.Parse(x)).ToArray();

        Compute(numOfWeights, weights);
    }

    private static void Compute(int numOfWeights, int[] weights) {
        var totals = new int[numOfWeights + 1, 2];
        var diffs = new int[2];
        totals[0, 0] = diffs[0] = weights.Sum();

        for (var boundary = 1; boundary <= numOfWeights; boundary++) {
            totals[boundary, 0] = totals[boundary - 1, 0] - weights[boundary - 1];
            totals[boundary, 1] = totals[boundary - 1, 1] + weights[boundary - 1];

            if (totals[boundary, 1] - totals[boundary, 0] >= 0) {
                diffs[0] = totals[boundary - 1, 0] - totals[boundary - 1, 1];
                diffs[1] = totals[boundary, 1] - totals[boundary, 0];
                break;
            }
        }

        var answer = diffs.Min().ToString();
        OutputAnswer(answer);
    }

    private static void OutputAnswer(string text) => Console.WriteLine(text);
}


Measured memory_bytes: 13396
#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;

int main(void){
    vector<int> a(3) ; cin >> a[0] >> a[1] >> a[2];
    int ans = *whole(max_element, a)  - *whole(min_element, a);
    cout << ans << endl;
}

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

#define TRACE(x) x
#define WATCH(x) TRACE(cout << #x" = " << x << endl)
#define WATCHR(a, b) TRACE(for (auto it=a; it!=b;) cout << *(it++) << " "; cout << endl)
#define WATCHC(V) TRACE({cout << #V" = "; WATCHR(V.begin(), V.end());})

#define all(x) (x).begin(), (x).end()

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

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

    vector<array<int, 2>> roads(3);
    for (int r = 0; r < 3; r++) {
        cin >> roads[r][0] >> roads[r][1];
    }

    sort(all(roads));
    do {
        bool m01 = roads[0][0] == roads[1][0] || roads[0][1] == roads[1][0];
        bool r01 = roads[0][0] == roads[1][1] || roads[0][1] == roads[1][1];
        bool m21 = roads[2][0] == roads[1][1] || roads[2][1] == roads[1][1];
        bool r21 = roads[2][0] == roads[1][0] || roads[2][1] == roads[1][0];
        if (m01 && m21 || r01 && r21) {
            cout << "YES\n";
            return 0;
        }
    } while (next_permutation(all(roads)));

    cout << "NO\n";
    return 0;
}



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

int main() 
{
    ll A, B; 
    cin >> A >> B;
    if((A + B)%2 == 0) cout << (A+B)/2 << endl;
    else cout << "IMPOSSIBLE" << endl;
    return 0;
}

Measured memory_bytes: 256