akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace abc139_b
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int A = int.Parse(input[0]);
            int B = int.Parse(input[1]);

            int  ana= 1;
            int kosuu= 0;

            while (ana<B)
            {
                ana += A - 1;
                kosuu += 1;
            }
            Console.Write(kosuu);
            Console.Read();
        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
#define INF 1e9+7

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

const int MAXN = 1e5+5;
int a[MAXN];

struct node {
	int s,e,m,v;
	node *l, *r;
	node (int _s, int _e) {
		s = _s, e = _e, m = (s+e)>>1;
		if (s!=e) {
			l = new node(s,m);
			r = new node(m+1,e);
			v = gcd(l->v,r->v);
		} else v = a[s];
	}
	void update(int qs, int nv) {
		if (s==e) {v = nv; return;}
		if (qs<=m) l->update(qs,nv);
		else r->update(qs,nv);
		v = gcd(l->v,r->v);
	}
	void printtree() {
		cerr<<s<<' '<<e<<' '<<v<<endl;
		if (s!=e) {
			l->printtree();
			r->printtree();
		}
	}	
} *seg;
		
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	for (int i = 0; i < n; ++i) cin >> a[i];
	int ans = 1;
	seg = new node(0,n-1);
	for (int i = 0; i < n; ++i) {
		seg->update(i,-INF);
		ans = max(ans,seg->v);
		seg->update(i,a[i]);
		//seg->printtree();
		//cerr<<endl;
		if (seg->v > ans) ans = seg->v;
	}
	cout << ans;
	//cout << (ans==-1?1:ans);
	return 0;
}


Measured memory_bytes: 9984
#include <iostream>
using namespace std;
int main(){
    string s;
    int n,i,j,k,f=0,p=0,a[26]={0};
    cin >> n >> s;
    for (i=0;i<n-1;i++){
        for (j=0;j<n-i-1;j++){
            for (k=0;k<=i;k++){
                if (s[j+i+1]==s[k]&&a[s[j+i+1]-'a']==0){
                    p++;
                    a[s[j+i+1]-'a']++;
                }
            }
        }
        if (f<p)
            f=p;
        p=0;
        for (j=0;j<26;j++)
            a[j]=0;
    }
    cout << f << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int mod = 1e9 + 7;

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

    int dp[n+2][k+2] = {0};
    for(int j=0;j<=k;j++){
        dp[1][j] = (j>a[1])?0:1;
    }

    for(int i=2;i<=n;i++){
        for(int j=0;j<=k;j++){
            if(j==0){
                dp[i][j] = dp[i-1][j];
            }
            else{
                dp[i][j] = dp[i][j-1] + dp[i-1][j];
                if(j-1-a[i]>=0)
                    dp[i][j] -= dp[i-1][j-1-a[i]];
                dp[i][j] = (dp[i][j] + mod)%mod;
            }
        }
    }

    cout<<dp[n][k]<<endl;

	return 0;
}

Measured memory_bytes: 82432
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
#define int long
#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define pb push_back
#define fi first
#define se second
const int INF = 1e9;
using namespace std;

signed main() {
    int K; cin >> K;
    int a=K/50,N=K%50;
    int A[50];
    rep(i,50){
        A[i]=K/50+i;
    }
    rep(i,N){
        A[i]+=50;
        rep(j,50) if(i!=j)A[j]--;
    }
    cout << 50 << endl;
    rep(i,50){
        cout << A[i] << (i==49?"":" ");
    }
    cout << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef pair<P,int> T;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define LLINF 1000000000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
struct Imos2D{
	int v[1015][1015];
	void set(int i,int j){
		i++; j++;
		v[i][j]++;
	}
	void calc(){
		for(int i=0;i<1010;i++){
			for(int j=0;j<1010;j++){
				v[i][j+1] += v[i][j];
			}
		}
		for(int i=0;i<1010;i++){
			for(int j=0;j<1010;j++){
				v[i+1][j] += v[i][j];
			}
		}
	}
	int rect(int a,int b,int c,int d){ //[a,c][b,d]
		a++; b++; c++; d++;
		if(a>c||b>d)return 0;
		return v[c][d]-v[a-1][d]-v[c][b-1]+v[a-1][b-1];
	}
};
int N,K;
int x[100100],y[100100];
char c[100100];
Imos2D A[2];
int main(){
	scanf("%d %d",&N,&K);
	for(int i=0;i<N;i++){
		scanf("%d %d %c",&x[i],&y[i],&c[i]);
	}
	for(int i=0;i<N;i++){
		int X = x[i]%K;
		int Y = y[i]%K;
		int d = (x[i]/K+y[i]/K)%2;
		if(c[i]=='B')A[d].set(X,Y);
		else A[!d].set(X,Y);
	}
	for(int i=0;i<2;i++)A[i].calc();
	int ans = 0;
	for(int i=0;i<=K;i++){
		for(int j=0;j<=K;j++){
			int res = A[0].rect(0,0,i-1,j-1)+A[0].rect(i,j,K-1,K-1);
			res += A[1].rect(0,j,i-1,K-1)+A[1].rect(i,0,K-1,j-1);
			ans = max(ans,res);
			ans = max(ans,N-res);
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 9344
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  int N;
  cin >> N;
  vector<int> L(N);
  for (int i = 0; i < N; i++) cin >> L[i];
  
  sort(L.begin(), L.end());
  int ans = 0;
  for (int i = 2; i < N; i++) {
    for (int j = 1; j < i; j++) {
      int a = L[i];
      int b = L[j];
      int c = abs(a-b) + 1;
      int iter = lower_bound(L.begin(), L.end(), c) - L.begin();
      ans += max(j - iter, 0);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using vec=vector<ll>;
using mat=vector<vec>;
#define For(i,a,b) for(i=a;i<b;i++)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define all(v) (v).begin(),(v).end()
#define vsort(v) sort(all(v))
#define mod 1000000007
using data=pair<ll,ll>;

long mmid(long a,long b,long c){return a<b?(b<c?b:max(a,c)):(b>c?b:min(a,c));}

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

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

ll modncr(ll n,ll r){
  ll i,plus=1;
  rep(i,r){
    plus=(plus*(n-i))%mod;
    plus=moddevide(plus,i+1);
  }
  return plus;
}

ll euclidean_gcd(ll a, ll b) {
  if(a<b) return euclidean_gcd(b, a);
  ll r;
  while ((r=a%b)){a=b;b=r;}
  return b;
}

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

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

void printmap(vector<ll>& a,ll H,ll W){
  ll i,j;
  For(i,0,H+2){
    For(j,0,W+2){cout<<a[i*(W+2)+j];}
    cout<<endl;
  }
}
void inputmap(vector<ll>& a,ll H,ll W){
  ll i,j;
  string ss;
  For(i,1,H+1){
    cin>>ss;
    For(j,1,W+1){
      if(ss[j-1]=='#'){
        a[i*(W+2)+j]=1;
      }else{
        a[i*(W+2)+j]=0;
      }
    }
  }
}


int main(){
  ll i,j,N,M,K;
  cin>>N>>K;
  if((N+K)%2==0){
    cout<<(N+K)/2<<endl;
  }else{
    cout<<"IMPOSSIBLE"<<endl;
  }
  return 0;
}

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

using namespace std;

struct load{
	int d;	//道の長さ
	int p;	//期待値
	bool operator<( const load& right ) const {
        return p == right.p ? d < right.d : p < right.p;
    }
};

int main(void){
	//FILE* fp_in = freopen("data.txt", "r", stdin);

	while(1) {
		int N, M;
		vector<load> l;
		cin >> N >> M;

		if( N == 0 && M == 0 ) break;
		for(int i = 0; i < N; i++) {
			int d,p;
			cin >> d >> p;
			load nl;
			nl.d = d;
			nl.p = p;
			l.push_back(nl);
		}

		sort( l.begin(), l.end() );
		for(int i = l.size() - 1 ; i >= 0 && M > 0 ; i --) {
			if( M - l.at(i).d >= 0 ) {
				M -= l.at(i).d;
				l.at(i).d = 0;
			} else if( M - l.at(i).d < 0 ) {
				l.at(i).d -= M;
				M = 0;
			}
		}

		int ans = 0;
		for(int i = 0; i < l.size(); i++)
			ans += l.at(i).d * l.at(i).p;

		cout << ans << endl;
	}

	//while(1){}

	return 0;
}

Measured memory_bytes: 1348
#define _USE_MATH_DEFINES // for C++  
#include <cmath> 
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <array>
#include <iterator>
#include <utility>
#include <set>
#include <random>
#include <map>
#include <stack>
#include <queue>
#include <list>
#include <functional>
#define LL long long


using namespace std;

int main() {
    int n, m;
    int min, min_ans;
    vector<int> a, b, c, d;
    cin >> n >> m;
    for (size_t i = 0; i < n; i++)
    {
        int tmp1, tmp2;
        cin >> tmp1 >> tmp2;
        a.emplace_back(tmp1);
        b.emplace_back(tmp2);
    }
    for (size_t i = 0; i < m; i++)
    {
        int tmp3, tmp4;
        cin >> tmp3 >> tmp4;
        c.emplace_back(tmp3);
        d.emplace_back(tmp4);
    }
    for (size_t i = 0; i < n; i++)
    {
        for (size_t j = 0; j < m; j++)
        {
            if (j==0)
            {
                min = abs(a[i] - c[j]) + abs(b[i] - d[j]);
                min_ans = j + 1;
                continue;
            }
            if (abs(a[i]-c[j])+abs(b[i]-d[j]) < min)
            {
                min = abs(a[i] - c[j]) + abs(b[i] - d[j]);
                min_ans = j + 1;

            }
        }
        cout << min_ans << endl;
    }
    return 0;
}   


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

ll gcd(ll a,ll b){
  if(b == 0) return a;
  return gcd(b , a % b);
}

ll mod(ll a){
  return (a % 1000000007);
}

ll lcm(ll a,ll b){
  return (a*b)/gcd(a,b);
}


int main(){
  ll a,b,c; cin >> a >> b >> c;
  cout << min(b/a,c) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <set>
#include <algorithm>
#include <vector>
#include <sstream>
#include <string>
#include <functional>
#include <queue>
#include <deque>
#include <stack>
#include <limits>
#include <unordered_map>
#include <unordered_set>
#include <cmath>
#include <fstream>
#include <iterator>
#include <random>
#include <chrono>


#define forr(i,start,count) for (int i = (start); i < (start)+(count); ++i)
#define set_map_includes(set, elt) (set.find((elt)) != set.end())
#define readint(i) int i; cin >> i
#define readll(i) ll i; cin >> i
#define readdouble(i) double i; cin >> i
#define readstring(s) string s; cin >> s

typedef long long ll;

using namespace std;

ll modd = 1000 * 1000 * 1000 + 7;

int digitssum(int n) {
    int ret = 0;
    while (n>0) {
        ret += n%10;
        n/=10;
    }
    return ret;
}


int main()   {

      ios_base::sync_with_stdio(false);

      cout.precision(17);
      mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
      uniform_int_distribution<int> rand_gen(0, modd);   // rand_gen(rng) gets the rand no

//    readint(test_cases);
    int test_cases = 1;
    forr(t, 1, test_cases) {
        readint(n);
        int ret = 10000000;
        forr(i,1,n-1) {
            ret = min(ret, digitssum(i)+digitssum(n-i));
        }
        cout << ret << endl;
    }
    return 0;
}


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


int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  rep(i,s.size()){
    s[i] = (s[i]-'A'+n)%26+'A';
  }
  cout << s << endl;
  return 0;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(1, in, out);
        out.close();
    }

    static class Task {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int[] array = new int[]{in.nextInt(), in.nextInt(), in.nextInt()};
            Arrays.sort(array);
            out.append(Arrays.equals(array, new int[]{5, 5, 7}) ? "YES" : "NO");
        }

    }
}



Measured memory_bytes: 21460
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1000000007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;
#define REP(i, n) for(ll i=0; i<(ll)(n); i++)
#define REPD(i, n) for(ll i=n-1; 0<=i; i--)
#define FOR(i, a, b) for(ll i=a; i<(ll)(b); i++)
#define FORD(i, a, b) for(ll i=a; (ll)(b)<=i; i--)
#define ALL(x) x.begin(), x.end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

int main(){
    int n, k;   cin >> n >>k;
    string s;   cin >> s;
    int cnt=1;
    REP(i, n-1)
        if(s[i]!=s[i+1]) cnt += 1;
    cout << n - max(1, cnt-2*k) << endl;
    
}

Measured memory_bytes: 512
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

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

typedef long long lint;

using namespace std;

int main(){
  lint a=100;
  lint X;
  cin>>X;
  REP(i,1e4){
    a*=1.01;
    if(a>=X){
      cout<<i+1<<endl;
      break;
    }
  }
  return 0;
}


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

using LL = long long;

#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define FOR(i, a, b) for (int(i) = (a); (i) < (b); ++(i))
#define RFOR(i, a, b) for (int(i) = (a); (i) > (b); --(i))
#define SORT(x) sort(ALL((x)))
#define RSORT(x) sort(RALL((x)))
#define SZ(x) (int)(x).size()
#define debug(x) cerr << #x << " : " << x << '\n'

const int INF = 1e9;
const int MOD = 1e9 + 7;
const LL LINF = 1e18;

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

  LL ans;
  LL a, b, x;
  cin >> a >> b >> x;

  LL A = a / x;
  LL B = b / x;

  ans = B - A;

  if((a % x) == 0){
    ans++;
  }

  cout << ans << '\n';

  return 0;
}

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

using namespace std;
typedef long long LL;

int main()
{
	vector<LL> v(4);
	for (int i = 0; i < 4; i++) {
		cin >> v[i];
	}
	LL N;
	cin >> N;

	LL M = (N/2)*2;

	LL cost = 1LL<<60;
	vector<long double> d = {4,2,1,0.5};
	for (int i = 0; i < 4; i++) {
		LL c = (M*d[i])*v[i];
		cost = min(cost, c);
	}
	N -= M;
	if (N > 0) {
		LL cost2 = 1LL<<60;
		for (int i = 0; i < 3; i++) {
			LL c = 1*d[i]*v[i];
			cost2 = min(cost2, c);
		}
		cost += cost2;
	}
	cout << cost << endl;
	exit(0);
}



Measured memory_bytes: 256
//ITP1_9_B_19140837_Ojima_Yukiya.cpp
//提出日 2020/6/17 wednesday
//プログラミング基礎演習2 CS 第６回課題 ITP1_9_B
//学修番号 19140837　小島優希也

#include <iostream>
#include <vector>
using namespace std;

int main(void) {
    vector<string> vec;
    while (true) {
        string s;
        cin >> s;
        if (s == "-") {
            break;
        }
        else {
            int m;
            cin >> m;
            string s1 = s;
            for (int i = 0; i < m; i++) {
                int h;
                cin >> h;
                string s2 = "";
                for (int j = h; j < s1.size(); j++) {
                    s2.push_back(s1.at(j));
                }
                for (int j = 0; j < h; j++) {
                    s2.push_back(s1.at(j));
                }
                s1 = s2;
            }
            vec.push_back(s1);
        }
    }
    for (string e : vec) {
        cout << e << endl;
    }
    return 0;
}


Measured memory_bytes: 3164
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
k=int(input())
nums = []
nums.append(a)
nums.append(b)
nums.append(c)
nums.append(d)
nums.append(e)
ans = 0
for i in nums:
    for j in nums:
        if abs(i-j)>k:
            ans+=1
if ans==0:
    print("Yay!")
else:
    print(":(")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;n>i;++i)
using namespace std;
using ll=int64_t;
using vi=vector<int>;
using VI=vector<ll>;
using vis=vector<string>;
using vvi=vector<vi>;
int gcd(int a,int b){
    if(a%b==0)
    return b;
    return gcd(b,a%b);
}
int main(){
    int x;
    cin>>x;
    if(x>=400&&x<600){
        cout<<8<<endl;
        return 0;
    }
    if(x>=600&&x<800){
        cout<<7<<endl;
        return 0;
    }
    if(x>=800&&x<1000){
        cout<<6<<endl;
        return 0;
    }
    if(x>=1000&&x<1200){
        cout<<5<<endl;
        return 0;
    }
    if(x>=1200&&x<1400){
        cout<<4<<endl;
        return 0;
    }
    if(x>=1400&&x<1600){
        cout<<3<<endl;
        return 0;
    }
    if(x>=1600&&x<1800){
        cout<<2<<endl;
        return 0;
    }
    if(x>=1800&&x<2000){
        cout<<1<<endl;
        return 0;
    }
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string s,n,p;
  cin>>s>>n>>p;
  char x,y,z,y1;
  x=s[s.size()-1];
  y=n[0];
  y1=n[n.size()-1];
  z=p[0];
  if(x==y&&y1==z)
  {
      cout<<"YES"<<endl;
  }
  if(x!=y&&y1==z)
  {
      cout<<"NO"<<endl;
  }
   if(x!=y&&y1!=z)
  {
      cout<<"NO"<<endl;
  }
   if(x==y&&y1!=z)
  {
      cout<<"NO"<<endl;
  }

}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int nam = sc.nextInt();
		int nam2 = sc.nextInt();
		
		int ans = -1;
		if(nam>=1 && nam<=9){
		    if(nam2>=1 && nam2<=9){
		        ans = nam * nam2;
		    }
		}
		
		System.out.println(ans);
	}
}


Measured memory_bytes: 21716
#include <stdio.h>

int main() {
    int n, x, d, c, count;
    scanf("%d %d", &n, &x);
    d = count = 0;

    for (int i = 0; i < n; i++) {
        scanf("%d", &c);
        if (d + c <= x) {
            d += c;
            count++;
        } else 
            break;
    }

    printf("%d\n", count + 1);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const ll mod = 1000000007;
const int INF = 1001001001;
const ll LINF = 1001001001001001001;

int main(){
    ll n , x; cin >> n >> x;
    vector<ll> a(n);
    rep(i,n) cin >> a.at(i);

    ll left = a.at(0), right;
    ll ans = 0;

    for(int i=1;i<n;i++){        
        right = a.at(i);
        if(left+right<=x){
            left = right;
            continue;
        }
        if(x-left>=0){
            ans += right-(x-left);
            left = x-left;
        }else{
            ans += left - x;
            ans += right;
            left = 0;
        }
    }
    cout << ans << endl;
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << fixed << setprecision(15);

  string w;
  cin >> w;

  unordered_map<char, int> cnt;

  for (char c : w) {
    if (cnt.count(c)) {
      ++cnt[c];
    } else {
      cnt[c] = 1;
    }
  }

  string ans = "Yes";
  for (char c : w) {
    if (cnt[c] % 2 == 1) {
      ans = "No";
    }
  }

  cout << ans << '\n';

  return 0;
}


Measured memory_bytes: 3620
function parse(input) {
  const arr = input.split("\n")[0].split(" ")
  const n = parseInt(arr[0], 10)
  const k = parseInt(arr[1], 10)

  return [n, k]
}

function f(n, k) {
  return Math.ceil(n / k) - Math.floor(n / k)
}

module.exports = {
  f,
  parse,
}

function Main(input) {
  const arr= parse(input)
  const n = arr[0]
  const k = arr[1]

  console.log(f(n, k))
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"))


Measured memory_bytes: 8900
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<bitset>
#include<deque>
#include<functional>
#include<iterator>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<utility>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz(x) (ll)((x).size())
#define pb push_back
#define mp make_pair
#define bg begin()
#define ed end()
#define all(x) (x).bg,(x).ed
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep1(i,n) for(ll i=1;i<=(n);i++)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(ll i=(n);i>=1;i--)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
const ll MOD=1000000007;
const ll INF=1000000000000000;
template<class T> inline bool chmin(T& a, T b){if(a>b){a=b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a=b;return true;}return false;}
ll maxx(ll x,ll y,ll z){return max(max(x,y),z);}
ll minn(ll x,ll y,ll z){return min(min(x,y),z);}
ll gcd(ll x,ll y){if(x%y==0) return y;else return gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}
ll digsz(ll x){if(x==0) return 1;else{ll ans=0;while(x){x/=10;ans++;}return ans;}}
ll digsum(ll x){ll sum=0;while(x){sum+=x%10;x/=10;}return sum;}
vector<ll> pw2(62,1);vector<ll> pw10(19,1);

ll mod_pow(ll x,ll n,ll mod){
    ll res=1;
    while(n>0){
        if(n&1) res=res*x%mod;
        x=x*x%mod;
        n>>=1;
    }
    return res;
}
long long modinv(long long a){
    long long b=MOD,u=1,v=0;
    while(b){
      long long t=a/b;
      a-=t*b;
      swap(a,b);
      u-=t*v;
      swap(u,v);
    }
    u%=MOD;
    if(u<0) u+=MOD;
    return u;
}
 
long long dev(long long a,long long b){
    return (a*modinv(b))%MOD;
}
 
long long comb(int x,int y){
  long long tmp=1;
    for(int i=0;i<y;i++){
        tmp=dev(tmp*(x-i)%MOD,i+1);
    }
  return tmp;
}


int main(){
    {rep1(i,61) pw2[i]=2*pw2[i-1];}
    {rep1(i,18) pw10[i]=10*pw10[i-1];}
    
    ll N,A,B; cin>>N>>A>>B;
    ll tmp=mod_pow(2,N,MOD)-1;
    tmp-=comb(N,A);
    if(tmp<0) tmp+=MOD;
    tmp-=comb(N,B);
    if(tmp<0) tmp+=MOD;
    cout<<tmp<<endl;
}


Measured memory_bytes: 3600
#include <iostream>
#include <iomanip>
#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 <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

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

const ll MOD=1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
const double eps=1e-10;

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

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

    vector<ll> sum(n+1, 0);
    for(int i=0; i<n; i++) sum[i+1] = sum[i] + a[i];

    ll ans=INF;
    for(int mid=2; mid<=n-2; mid++){
        ll lsum = sum[mid];
        ll rsum = sum[n] - sum[mid];

        int l = lower_bound(sum.begin(), sum.end(), lsum / 2) - sum.begin();
        int r = lower_bound(sum.begin(), sum.end(), sum[mid] + rsum / 2) - sum.begin();

        ll pqgap = INF;
        ll P, Q;
        for(int i=-1; i<=1; i++){
            ll psum = sum[max(1, l+i)];
            ll qsum = sum[mid] - psum;

            if(abs(psum - qsum) < pqgap){
                pqgap = abs(psum - qsum);
                P = psum;
                Q = qsum;
            }
        }

        ll rsgap = INF;
        ll R, S;
        for(int i=-1; i<=1; i++){
            ll rsum = sum[max(mid+1, r+i)] - sum[mid];
            ll ssum = sum[n] - sum[max(mid+1, r+i)];

            if(abs(rsum - ssum) < rsgap){
                rsgap = abs(rsum - ssum);
                R = rsum;
                S = ssum;
            }
        }

        ll ma = max({P, Q, R, S});
        ll mi = min({P, Q, R, S});

        chmin(ans, ma - mi);
    }

    cout << ans << endl;
}

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

int bitnum(int n) {
	n = (n&0x55555555) + ((n>>1)&0x55555555);
	n = (n&0x33333333) + ((n>>2)&0x33333333);
	n = (n&0x0f0f0f0f) + ((n>>4)&0x0f0f0f0f);
	n = (n&0x00ff00ff) + ((n>>8)&0x00ff00ff);
	return (n&0x0000ffff) + ((n>>16)&0x0000ffff);
}

int main() {
	int n, s;
	while (cin >> n >> s, n||s) {
		int num = 0;
		for (int i = 0; i < 1<<10; i++) {
			if (bitnum(i) != n) continue;
			int sum = 0;
			for (int j = 0; j < 10; j++)
				if ((i>>j) & 1)
					sum += j;
			if (sum == s)
				num++;
		}
		cout << num << endl;
	}
	return 0;
}

Measured memory_bytes: 0
n, m, c = map(int, input().split())
B = list(map(int, input().split()))

count = 0
for _ in range(n):
    A = list(map(int, input().split()))
    judge = c
    for a, b in zip(A, B):
        judge += a * b
    if judge > 0:
        count += 1

print(count)


Measured memory_bytes: 38256
#include <cstdio>

int H1, M1, H2, M2, K;

int main() {
  scanf("%d %d %d %d %d", &H1, &M1, &H2, &M2, &K);

  int diff = H2 * 60 + M2 - (H1 * 60 + M1);
  printf("%d\n", diff-K);
}


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

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

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

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

	
	long long cnt=0;
	for(int i=0;i<N-K;i++){
		cnt += H[i];
	}
	cout << cnt << endl;
}


Measured memory_bytes: 1024
#include <stdio.h>

int a , b , c;

int main ()  {

	scanf ("%d %d %d" , &a , &b ,&c);
	
	if (a<b && b<c) {
		printf ("Yes\n" );
	}	else  {
		
		printf ("No\n" );
	}
	return 0;
	
}


Measured memory_bytes: 2036
#!python3

# input
N = int(input())
A = list(map(int, input().split()))


def comb2(n):
    if n < 1:
        return 0
    else:
        return n * (n - 1) // 2


def main():
    w = {}
    for a in A:
        if a in w:
            w[a] += 1
        else:
            w[a] = 1
    
    v = 0
    for x in w.values():
        v += comb2(x)
    
    for a in A:
        ans = v - (comb2(w[a]) - comb2(w[a] - 1))
        print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 26140
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<queue>
#define ll long long
using namespace std;

int n, m, ans = 0;
bool a[8][8] = {}, b[8] = {};


int dfs(int x, int t) {
	if (t == n - 1) {
		for (int i = 0; i < n; i++) {
			if (!b[i]) {
				b[x] = false;
				return ans;
			}
		}
		b[x] = false;
		return ans += 1;
	}
	for (int i = 0; i < n; i++) {
		if (a[x][i] && !b[i]) {
			b[i] = true;
			ans = dfs(i, t + 1);
			b[i] = false;
		}
	}
	return ans;
}

int main() {
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		int tmp1, tmp2;
		cin >> tmp1 >> tmp2;
		tmp1--; tmp2--;
		a[tmp1][tmp2] = a[tmp2][tmp1] = true;
	}
	b[0] = true;
	cout << dfs(0, 0) << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int index = Integer.parseInt(sc.nextLine());
        String[] str = sc.nextLine().split(" ");

        for(int loopcnt = str.length; loopcnt > 0; loopcnt--){
            if( loopcnt != 1 ) System.out.print(str[loopcnt-1] + " ");
            else System.out.print(str[loopcnt-1]);
        }
        System.out.println();
    }
}


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

int main() {
  int a,b,c;
  cin >> a >> b >> c;

  if (a==b && a!=c) {
    cout << "Yes";
    return 0;
  }
  
  if (a!=b && a==c) {
    cout << "Yes";
    return 0;
  }

  if (b==c && a!=c) {
    cout << "Yes";
    return 0;
  }

  cout << "No";
  
  
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h> 
struct Node{ int key; 
struct Node *right,*left,*parent; 
    }; 
    struct Node *root,*NIL;
    
    struct Node * find(struct Node *u,int k){ 
    while(u != NIL && k != u->key){ 
        
        if(k<u->key)u=u->left; 
    else u = u->right; 
        
    } return u;
    } 
    
    void insert(int k){ 
        struct Node *y = NIL; 
        struct Node *x = root; 
        struct Node *z; 
        
        z = (struct Node *)malloc(sizeof(struct Node)); 
        z->key = k; z->left = NIL; 
        z->right = NIL; 
        
        while(x != NIL){ 
            y = x; 
            if(z->key < x->key){ x = x->left;
            }
            else{ x = x->right; 
                
            } 
            
        } 
        z->parent = y;
        
        
        if(y == NIL)root = z; 
            
        
        else{ 
            if(z->key < y->key){ 
                y->left = z; 
                
            }
            
            else  y->right = z; 
                
            
            } 
        
    } 
    void inorder(struct Node *u){ 
        if(u == NIL) return;
        inorder(u->left);
        
        printf(" %d",u->key); 
        inorder(u->right);
        } 
        
void preorder(struct Node *u){ 
    if(u == NIL) return; 
     printf(" %d",u->key); 
            
    preorder(u->left);
    
    preorder(u->right);
            } 
            
            
 int main(){ 
    int n,i,x; 
    char com[20]; 
    scanf("%d",&n); 
        
    for(i=0;i<n;i++){
    scanf("%s",com);
          
    if(com[0] == 'f'){ 
        
        scanf("%d",&x);
        struct Node *t = find(root,x);
        
       if(t != NIL)    
        printf("yes\n");
        
         else printf("no\n"); 
                            
        } 
        
                        
        else if(com[0] == 'i'){
    scanf("%d",&x); insert(x);
    } 
        else if(com[0] == 'p'){
    inorder(root);
    printf("\n"); 
    preorder(root);
    printf("\n"); 
    } 
             
         } 
    
    return 0; 
            
        }


Measured memory_bytes: 20448
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define inf (int)(3e18)

template<class T> inline void chmin(T &a, T b) {
	a = min(a, b);
}
template<class T> inline void chmax(T &a, T b) {
	a = max(a, b);
}


signed main() {
	int N,M;
	cin>>N>>M;
	cout<<N*(N-1)/2+M*(M-1)/2<<endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <bitset>
#include <math.h>

typedef long long ll;
typedef unsigned long long ull;

#define vi std::vector<int>
#define vl std::vector<ll>
#define floop(n) for(int i = 0; i < n; ++i)
#define print(x) std::cout << x << std::endl;

const ll INF = 1e18;

int main()
{
    std::string S;
    int n = 0;
    std::cin >> S;

    if(S[0] == 'R' && S[1] == 'R' && S[2] == 'R')
        n = 3;
    else if((S[0] == 'R' && S[1] == 'R' && S[2] == 'S') || (S[0] == 'S' && S[1] == 'R' && S[2] == 'R'))
        n = 2;
    else if((S[0] == 'R' && S[1] == 'S' && S[2] == 'S') || 
            (S[0] == 'S' && S[1] == 'R' && S[2] == 'S') || 
            (S[0] == 'S' && S[1] == 'S' && S[2] == 'R') || 
            (S[0] == 'R' && S[1] == 'S' && S[2] == 'R'))
        n = 1;
    else
        n = 0;
        
    print(n);
    return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int MAX=1e5+10;
int N,A[MAX],B[MAX],C[MAX],dp[MAX][3];
int solve(int idx,int pr)
{
    if(idx>N)return 0;
    if(dp[idx][pr]!=-1)return dp[idx][pr];
    int res=0;
    for(int i=1;i<=3;i++){
        if(i==pr)continue;
        int val=0;
        if(i==1)val=A[idx];
        if(i==2)val=B[idx];
        if(i==3)val=C[idx];
        res = max(res,solve(idx+1,i)+val);
    }
    return dp[idx][pr]=res;
}
int  main ()
{
    memset(dp,-1,sizeof dp);
    cin >> N;
    for(int i=1;i<=N;i++){
        cin >> A[i] >> B[i] >> C[i];
    }
    cout<<solve(1,0)<<endl;
    return 0;
}




Measured memory_bytes: 8832
K = int(input())
list = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

print(list[K-1])

Measured memory_bytes: 3060
n,m = gets.split.map(&:to_i)
xyz = []
n.times do |i|
  xyz << gets.split.map(&:to_i)
end

def score(list, sign="111", m)
  x,y,z = 0,0,0
  list = list.sort_by do |e|
    sum = 0
    (0..2).each do |i|
      sum += sign[i] == '1' ? e[i] : -e[i]
    end
    -sum
  end
  list[0...m].each do |e|
    x += e[0]
    y += e[1]
    z += e[2]
  end
  x.abs+y.abs+z.abs
end
ans = []
ans << score(xyz, "111", m)
ans << score(xyz, "011", m)
ans << score(xyz, "101", m)
ans << score(xyz, "110", m)
ans << score(xyz, "001", m)
ans << score(xyz, "100", m)
ans << score(xyz, "010", m)
ans << score(xyz, "000", m)
puts ans.max

Measured memory_bytes: 2296
/**
 *    author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *    created : 2020-04-06 13:18:59
**/

#include <iostream>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
#include <bitset>
#include <cassert>
#include <cctype>
#include <iomanip>
#include <random>
#include <utility>
#include <chrono>

using namespace std;

using int64 = long long;

template<class T> using binary_heap = std::priority_queue<T, std::vector<T>, std::greater<T>>;
template<class T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) { os << '{'; size_t n = vec.size(); for (size_t i = 0; i < n; ++i) { os << vec[i]; if (i != n - 1) os << ','; } os << '}'; return os; }
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) { return os << '{' << p.first << " " << p.second << '}'; }
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) { os << '{'; for (auto it = mp.begin(); it != mp.end(); ++it) { os << '{' << it->first << ':' << it->second << '}'; if (it != --mp.end()) os << ','; } os << '}'; return os; }
template<class T> std::ostream& operator<<(std::ostream& os, const std::set<T>& st) { os << '{'; for (auto it = st.begin(); it != st.end(); ++it) { os << *it; if (it != --st.end()) os << ','; } os << '}'; return os; }
template<class T> std::istream& operator>>(std::istream& is, std::vector<T>& vec) { size_t n = vec.size(); for (size_t i = 0; i < n; ++i) is >> vec[i]; return is; }

#define all(_) begin(_), end(_)
#define rall(_) rbegin(_), rend(_)

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...) 1728
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}

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

  int k; cin >> k;

  vector<string> v;

  auto rec = [&](const auto& rec, string s) -> void {
    v.emplace_back(s);
    if (s.size() >= 11) {
      return ;
    } else {
      char cur = s.back();
      char pre = (char) (cur - 1);
      char nxt = (char) (cur + 1);
      if (s.back() == '0') {
        rec(rec, s + cur);
        rec(rec, s + nxt);
      } else if (s.back() == '9') {
        rec(rec, s + pre);
        rec(rec, s + cur);
      } else {
        rec(rec, s + pre);
        rec(rec, s + cur);
        rec(rec, s + nxt);
      }
    }
  };

  for (int i = 1; i < 10; ++i) {
    rec(rec, to_string(i));
  }

  sort(all(v), [](const string& x, const string& y){
    if (x.size() == y.size()) {
      return x < y;
    } else {
      return x.size() < y.size();
    }
  });

  cout << v[k - 1] << endl;

  return 0;
}

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

const int MAX = 510000;
const int MOD = 1000000007;
const int MAX_N = 200000;

int ctoi(const char c){
 switch(c){
   case '0': return 0;
   case '1': return 1;
   case '2': return 2;
   case '3': return 3;
   case '4': return 4;
   case '5': return 5;
   case '6': return 6;
   case '7': return 7;
   case '8': return 8;
   case '9': return 9;
   default : return -1;
 }
}

int main(int argc, const char * argv[]) {
  ll N,K; cin >> N >> K;
  ll ans=0;
  vector<ll> A(N);
  for(ll i=0;i<N;i++){
    cin >> A[i];
  }
  vector<ll> S(N+1);
  S[0]=0;
  for(ll i=0;i<N;i++){
    S[i+1]=S[i]+A[i];
  }

  map<ll,ll> MAP;
  for(ll i=0;i<=N;i++){
    ans+=MAP[(S[i]-i)%K];
    MAP[(S[i]-i)%K] += 1 ;
    if(i>=K-1){
      MAP[(S[i-K+1]-(i-K+1))%K] -= 1 ;
    }
  }

  // for(auto x : MAP){
  //   cout << "key : " << x.first << "  value : " << x.second << endl;
  // }

  cout << ans << endl;

  return 0;
}


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

using namespace std;

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15);
  }
} initializer;

int main() {
  int a, b, c, t = 0;
  cin >> a >> b >> c;
  for (int i = 0; ; ++i) {
    if (t % 60 <= c && c <= t % 60 + a) {
      cout << t + c - t % 60 << endl;
      return 0;
    }
    t += a + b;
    if (t > 3600) break;
  }
  cout << -1 << endl;
}

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

int main(){
    int H,N;
    cin >> H >> N;
    int A[N],sum=0;
    for(int i=0;i<N;i++){
        cin >> A[i];
        sum += A[i];
    }
    if(H <= sum) cout << "Yes";
    else cout << "No";
}

Measured memory_bytes: 640
import sys
input = sys.stdin.readline

def main():
	Y, M, D = map(int, input().split('/'))
	if Y < 2019 or (M <= 4 and D <= 30):
		print("Heisei")
	else:
		if Y == 2019:
			if M >= 5:
				print("TBD")
			else:
				print("Heisei")
		else:
			print("TBD")

if __name__ == '__main__':
	main()

Measured memory_bytes: 2940
#include<iostream>
#include<cstring>
using namespace std;
int A[2][1000],G[2][1000][2];
string s,t;
int root;
int f(string s,int flag)
{
	int nowroot=root++;
	int i=0,cnt=0;
	for(;i<s.size();i++)
	{
		if(s[i]=='(')cnt++;
		else if(s[i]==')')cnt--;
		if(!cnt)break;
	}
	G[flag][nowroot][0]=i>1?f(s.substr(1,i-1),flag):-1;
	int j=i+2;
	for(;s[i]!=']';i++);
	A[flag][nowroot]=stoi(s.substr(j,i-j));
	G[flag][nowroot][1]=i+4<s.size()?f(s.substr(i+2,s.size()-i-3),flag):-1;
	return nowroot;
}
string solve(int a,int b)
{
	string ans="["+to_string(A[0][a]+A[1][b])+"]";
	ans="("+(G[0][a][0]>=0&&G[1][b][0]>=0?solve(G[0][a][0],G[1][b][0]):"")+")"+ans;
	ans+="("+(G[0][a][1]>=0&&G[1][b][1]>=0?solve(G[0][a][1],G[1][b][1]):"")+")";
	return ans;
}
main()
{
	cin>>s>>t;
	int aroot=f(s,0);
	root=0;
	int broot=f(t,1);
	cout<<solve(aroot,broot)<<endl;
}



Measured memory_bytes: 3396
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>//sort,reverse
#include<utility>//pair
#include<queue>//queue,priority_queue
#include<deque>//double_ended queue
using namespace std;
typedef pair<int,int> P;//Pでpair<-,->を表す。
typedef long long LL; 
LL MAX=100000000000;
LL MOD=1000000007;

int main()
{ 
    int h;
    cin>>h;
    int n;
    cin>>n;
    int a[n];
    int b[n];
    for(int i=0;i<n;i++){
        cin>>a[i]>>b[i];
    }
    LL x[20010];//体力をi削るのに必要な最小回数。
    for(int i=0;i<20010;i++){
        x[i]=MAX;
    }
    x[0]=0;
    for(int i=1;i<=20000;i++){
        for(int j=0;j<n;j++){
            int k=i-a[j];
            if(k>=0){
                if(x[i]>x[k]+b[j]){x[i]=x[k]+b[j];}
            }
        }
    }
    LL ans=MAX;
    for(int i=h;i<=20000;i++){
        if(ans>x[i]){ans=x[i];}
    }

    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define forn(i, n) for (long long i = 0; i < (long long)(n); ++i)
#define for1(i, n) for (long long i = 1; i <= (long long)(n); ++i)
#define fore(i, l, r) for (long long i = (long long)(l); i <= (long long)(r); ++i)
#define fordn(i, n) for (long long i = (long long)(n) - 1; i >= 0; --i)
#define ford1(i, n) for (long long i = (long long)(n); i >= 1; --i)
#define all(x) (x).begin(), (x).end()
#define PI 3.141592653589793
using namespace std;
using ll = long long;
using ld = long double;

int main(){
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int a, b;
    cin >> a >> b;
    if(a == b) cout << "Draw" << endl;
    else if(a == 1) cout << "Alice" << endl;
    else if(b == 1) cout << "Bob" << endl;
    else if(a > b) cout << "Alice" << endl;
    else cout << "Bob" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <cmath>
#include <cassert>
using namespace std;

int main(){
    int N;
    cin >> N;
    vector<long long> A(N+1), B(N);
    for(int i=0; i<N+1; i++) cin >> A[i];
    for(int i=0; i<N; i++) cin >> B[i];
    long long ans = 0;
    for(int i=0; i<N; i++){
        long long mn = min(A[i], B[i]);
        A[i] -= mn;
        B[i] -= mn;
        ans += mn;

        mn = min(A[i+1], B[i]);
        A[i+1] -= mn;
        B[i] -= mn;
        ans += mn;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
import numpy as np

N, M, C = map(int, input().split())
B = np.array(list(map(int, input().split())))

cnt = 0
for i in range(N):
    a = np.array(list(map(int, input().split())))
    if np.sum(a * B) + C > 0:
        cnt += 1

print(cnt)


Measured memory_bytes: 12504
#https://atcoder.jp/contests/abc120/submissions/4458925
(N,M) = map(int,input().split())
A = [0]*M
B = [0]*M
for i in range(M):
    (A[i], B[i]) = map(int,input().split())
    A[i] -= 1
    B[i] -= 1
 
parent = [-1]*N
depth = [0] * N
 
def boss(n):
    d = 0
    while parent[n] >= 0:
        n = parent[n]
        d += 1
    return n,d
 
P = [1]*N
S = (N*(N-1))//2
 
ans = [0] * M
ans[M-1] = S
 
for i in range(M-1):
    j = M-1-i
    bA, dA = boss(A[j])
    bB, dB = boss(B[j])
    if bA != bB:
        if depth[bA] < depth[bB]:
            (bA, bB) = (bB, bA)
        parent[bB] = bA
        S -= P[bA]*P[bB]
        P[bA] = P[bA] + P[bB]
        P[bB] = 0
        depth[bA] = max(depth[bA],depth[bB]+1)
    ans[j-1] = S
 
for i in range(M):
    print(ans[i])

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

int main(){
  int a,b;
  cin >> a >> b;
  int ans=0;
  for(int i=1;i<a;i++){
    ans++;
  }
  if(a<=b){
    ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline

n = int(input())
num_list = [ int(input()) for i in range(n) ]

max_num = max(num_list)
max_count = num_list.count(max_num)

if max_count > 1:
    for i in num_list:
        print(max_num)
else:
    max_index = num_list.index(max_num)
    num_list[max_index] = -1
    second_num = max(num_list)
    num_list[max_index] = max_num

    for i in num_list:
        if i != max_num:
            print(max_num)
        else:
            print(second_num)

Measured memory_bytes: 57936
while line=gets
    while !(line=~/(the|this|that)/)
        for i in 0..line.size-1
            if (line[i]=~/[a-z]/)
                if (line[i]=~/z/)
                    line[i]='a'
                else
                    line[i]=line[i].succ
                end
            end
        end
    end
    puts line
end

Measured memory_bytes: 6144
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.ParseInt(sc.Text(), 10, 64)
	if e != nil {
		panic(e)
	}
	return int(i)
}

func main() {
	n := nextInt()

	fmt.Println(3 * n * n)
}


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

using ll = long long;

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

  int ans=0;

  if(n>=2)ans += n*(n-1)/2;
  if(m>=2)ans += m*(m-1)/2;

  cout << ans << endl;
}

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

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

    ll N, K, Q, n;
    cin >> N >> K >> Q;
    ll A[N];
    for(int i = 0; i < N; ++i) A[i] = K - Q;

    for (int i = 0; i < Q; ++i){
        cin >> n;
        A[n - 1]++;
    }

    for(int i = 0; i < N; ++i){
        
        if(A[i] > 0) cout << "Yes" << endl;
        else cout << "No" << endl;
    }


}

Measured memory_bytes: 1408
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <queue>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
const long long MOD = 1000000007LL;
const string alpha = "abcdefghijklmnopqrstuvwxyz";
int main(){
    long n;
    cin >> n;
    long long a[n];
    long long tem = 0;
    rep(i,n){
        cin >> a[i];
        tem = 2*a[i] - tem;
    }
    long long aa = tem/2;
    cout << aa << " ";
    rep(i,n-1){
        aa = 2*a[i]-aa;
        cout << aa << " ";
    }
    cout << endl;
}

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

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

    int n;
    cin >> n;
    vector<int> d(n);
    for (int i = 0; i < n; i++)
    {
        cin >> d[i];
    }
    sort(d.begin(), d.end());
    cout << (d[n / 2] - d[(n / 2) - 1]);
}

Measured memory_bytes: 3768
#include <bits/stdc++.h>
using ll = long long int;
using namespace std;
ll mod=1e9+7;
      
      
int main(){
  ll ans=0;
  ll n,k;
  cin >> n >> k;
  for(ll i=k;i<=n+1;i++){
    ll mint=(i-1)*i/2;
    ll maxt=(n+n-i+1)*i/2;
    ans+=maxt-mint+1;
    if(ans>mod){ans=ans%mod;}
  }
  cout << ans << endl;
}

Measured memory_bytes: 3636
s=input()
q=int(input())
c=1
u=''
for i in range(q):
    inp=input()
    if inp[0]=="1":
        c*=-1
    else:
        t,f,p=inp.split()
        if (f=="1" and c!=1) or (f=="2" and c==1):
            s+=p
        else:
        	u+=p
if c!=1:
    print("".join(reversed(s))+u)
else:
    print("".join(reversed(u))+"".join(s))

Measured memory_bytes: 5108
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <queue>

#define REP(i, a, b) for ( int i = (a); i < (b); i++ )
#define REVREP(i, a, b) for ( int i = (a); i >= (b); i--)
#define DEBUG_INT(var) printf("the value of "#var" is %d\n", var)
#define PRINT_ARRAY(name, i) printf("the value of "#name"[%d] is %d\n", (i), name[(i)])
#define DEBUG_ARRAY(name, begin, end) REP(i, begin, end) PRINT_ARRAY(name, i)

#define YES puts("YES")
#define NO  puts("NO")
#define Yes puts("Yes")
#define No  puts("No")

using namespace std;

typedef long long ll;

int N, Q;
vector<int> v[200005];
int s[200005];
bool f[200005];

void bfs() {
  queue<int> q;
  q.push(1);
  f[1] = true;
  while(!q.empty()) {
    int t = q.front(); q.pop();
    
    REP(i, 0, v[t].size()) {
      if (!f[v[t][i]]) {
        f[v[t][i]] = true;
        s[v[t][i]] += s[t];
        q.push(v[t][i]);
      }
    }
    
  }
  

}

int main(void) {
    scanf("%d %d", &N, &Q);
    REP(i, 1, N) {
      int a, b;
      scanf("%d %d", &a, &b);
      v[a].push_back(b);
      v[b].push_back(a);
    }
    
    REP(i, 0, Q) {
      int p, x;
      scanf("%d %d", &p, &x);
      s[p] += x;
    
    }
    
    
    bfs();
  
    REP(i, 1, N+1){
      if (i > 1) printf(" ");
      printf("%d", s[i]);
    }
    printf("\n");
	return 0;
}


Measured memory_bytes: 15732
#include<stdio.h>
int main()
{
	int a,b,c,x;
	scanf("%d %d %d",&a,&b,&c);
	x=b/a;
	if(x<c){
		printf("%d\n",x);
	}
	else{
		printf("%d\n",c);
	}
	return 0;
}


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

int main(){
    ll n;
    cin>>n;
    vector<ll> a(n);
    ll ans=0;
    for(ll i=0;i<n;++i){
        cin>>a[i];
    }
    sort(a.begin(), a.end());
    reverse(a.begin(), a.end());
    for(ll i=0;i<n;++i){
        if(i%2==1){
            ans -= a[i];
        }else{
            ans += a[i];
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256